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? –