3
我正在嘗試創建一個tcp wcf服務,該服務可以在沒有IIS的服務器上託管,並且無需身份驗證即可訪問該服務。如何託管公共WCF服務?
這裏是我做的:
ServiceHost svh = new ServiceHost(typeof(MyService));
var tcpbinding = new NetTcpBinding(SecurityMode.None);
var location = "net.tcp://localhost:11111";
svh.AddServiceEndpoint(typeof(IMyService), tcpbinding, location);
svh.Open();
....
該服務適用於locashost罰款,但是當我把它在服務器上(添加防火牆例外),客戶端與消息崩潰:
The socket connection was aborted. This could be caused by an error processing
your message or a receive timeout being exceeded by the remote host, or an
underlying network resource issue. Local socket timeout was '00:00:59.7344663'.
這裏的客戶端配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyService">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://myserver:11111/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService"
contract="MyServer.IMyService" name="NetTcpBinding_IMyService" />
</client>
</system.serviceModel>
</configuration>
我應該爲此換個工作?
您是否閱讀過http://msdn.microsoft.com/zh-cn/library/bb332338.aspx? –