wcf部署,通过IIS寄宿服务(net.tcp),免svc文件。

1.新建一个网站

2.在网站中新建一个应用程序(名称为WcfServicesForeBayLS)

3.在应用程序高级设置中,新增协议net.tcp

高级设置->行为->已启用协议->http,net.tcp

4.编辑网站绑定,添加net.tcp类型,在绑定信息中写入808:*

5.在应用程序中,将生成的.dll文件等放入bin文件夹下,此bin文件夹在应用程序根目录下

6.新建web.config文件,将app.config文件中的内容拷贝到web.config中,并稍作修改

附上修改前和修改后的config

修改前

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="ebayAccountLS.batchingHosting" type="eBayAccountLS.Server.Config.BatchingHostingSettings,eBayAccountLS.Server" />
</configSections>
<appSettings>
<add key="AccountInfoUrl" value="http://192.168.3.36:5566/Account/GetUserVPNLoginInfo"/>
<add key="RouteInfoUrl" value="http://192.168.3.36:5566/Account/GetAllVPNServerIP"/>
</appSettings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="portSharingBinding" portSharingEnabled="true" >
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<!--<serviceMetadata httpGetEnabled="true"/>-->
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="OtherService" behaviorConfiguration="metadataBehavior">
<endpoint address="net.tcp://127.0.0.1:4444/OtherService" binding="netTcpBinding" contract="IOtherService" bindingConfiguration="portSharingBinding" />
<!--用于发布元数据,debug时注释-->
<!--<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />-->
</service>
<service name="AccountService" behaviorConfiguration="metadataBehavior">
<endpoint address="net.tcp://127.0.0.1:4444/AccountService" binding="netTcpBinding" contract="IAccountService" bindingConfiguration="portSharingBinding"/>
<!--用于发布元数据,debug时注释-->
<!--<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />-->
</service>
<service name="PublicDuplexService" behaviorConfiguration="metadataBehavior">
<endpoint address="net.tcp://127.0.0.1:4444/PublicDuplexService" binding="netTcpBinding" contract="IPublicDuplexService" bindingConfiguration="portSharingBinding" />
<!--用于发布元数据,debug时注释-->
<!--<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />-->
</service>

</services>
<serviceHostingEnvironment>
<serviceActivations>
<add service="eBayAccountLS.Server.Services.AccountService,eBayAccountLS.Server" relativeAddress="AccountService.svc"/>
<add service="eBayAccountLS.Server.Services.OtherService,eBayAccountLS.Server" relativeAddress="OtherService.svc"/>
<add service="eBayAccountLS.Server.Services.PublicDuplexService,eBayAccountLS.Server" relativeAddress="PublicDuplexService.svc"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
<!--自定义配置节点,用于批量寄宿-->
<ebayAccountLS.batchingHosting>
<add type="eBayAccountLS.Server.Services.AccountService,eBayAccountLS.Server" />
<add type="eBayAccountLS.Server.Services.OtherService,eBayAccountLS.Server" />
<add type="eBayAccountLS.Server.Services.PublicDuplexService,eBayAccountLS.Server" />
</ebayAccountLS.batchingHosting>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

 

修改后

<?xml version="1.0"?>
<configuration>
<configSections>
<section name="ebayAccountLS.batchingHosting" type="eBayAccountLS.Server.Config.BatchingHostingSettings,eBayAccountLS.Server" />
</configSections>
<appSettings>
<add key="AccountInfoUrl" value="http://192.168.3.36:5566/Account/GetUserVPNLoginInfo"/>
<add key="RouteInfoUrl" value="http://192.168.3.36:5566/Account/GetAllVPNServerIP"/>
<add key="x" value="this is X" />
</appSettings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="portSharingBinding" portSharingEnabled="true" >
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="OtherService" behaviorConfiguration="metadataBehavior">
<endpoint binding="netTcpBinding" contract="IOtherService" bindingConfiguration="portSharingBinding" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="AccountService" behaviorConfiguration="metadataBehavior">
<endpoint binding="netTcpBinding" contract="IAccountService" bindingConfiguration="portSharingBinding"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="PublicDuplexService" behaviorConfiguration="metadataBehavior">
<endpoint binding="netTcpBinding" contract="IPublicDuplexService" bindingConfiguration="portSharingBinding"/>
<!--用于发布元数据,debug时注释-->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<serviceHostingEnvironment>
<serviceActivations>
<add service="eBayAccountLS.Server.Services.AccountService,eBayAccountLS.Server" relativeAddress="AccountService.svc"/>
<add service="eBayAccountLS.Server.Services.OtherService,eBayAccountLS.Server" relativeAddress="OtherService.svc"/>
<add service="eBayAccountLS.Server.Services.PublicDuplexService,eBayAccountLS.Server" relativeAddress="PublicDuplexService.svc"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

 

其中

<serviceHostingEnvironment>
<serviceActivations>
<add service="eBayAccountLS.Server.Services.AccountService,eBayAccountLS.Server" relativeAddress="AccountService.svc"/>
<add service="eBayAccountLS.Server.Services.OtherService,eBayAccountLS.Server" relativeAddress="OtherService.svc"/>
<add service="eBayAccountLS.Server.Services.PublicDuplexService,eBayAccountLS.Server" relativeAddress="PublicDuplexService.svc"/>
</serviceActivations>
</serviceHostingEnvironment>

功能在于,支持无.svc文件的服务激活

更详细的内容自行查阅

 

客户端终结点

<endpoint name="otherServiceEndPoint" address="net.tcp://192.168.3.36/WcfServicesForeBayLS/OtherService.svc" binding="netTcpBinding" contract="IOtherService" bindingConfiguration="portSharingBinding"/>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。