WCF服务调用使用basicHttpBinding但使用netTcpBinding失败

时间:2011-04-14 21:37:05

标签: wcf nettcpbinding was

(请阅读评论,因为我有一个修复)
您好,

我创建了一个WCF服务,我使用.net 4.0在Windows 7上的IIS 7.5中托管 该服务托管在http和net.tcp。

我使用WcfTestClient测试了我的服务,它似乎通过basicHttp和netTcp正常工作。

但是,当我尝试通过我的ASP.NET网站使用此服务时,我在尝试通过nettcp时收到错误

我的客户端点如下所示

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="Generic_HttpBinding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
      <security mode="None"/>
      <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
    </binding>
  </basicHttpBinding>
  <netTcpBinding>
    <binding name="Generic_Binding" sendTimeout="00:01:00" receiveTimeout="00:01:00" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000">
      <security mode="None"/>
      <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000"/>
    </binding>
  </netTcpBinding>
</bindings>
<client>
  <endpoint name="EndPointHttp" address="http://localhost:43/Service/MyService.svc" binding="basicHttpBinding" bindingConfiguration="Generic_HttpBinding" contract="NameSpace.Services.Contracts.IService"></endpoint>
  <endpoint name="EndPoint" address="net.tcp://localhost:42/Service/MyService.svc" binding="netTcpBinding" bindingConfiguration="Generic_Binding" contract="NameSpace.Services.Contracts.IService"></endpoint>
</client>

现在我以完全相同的方式调用服务,只需交换我的终点名称

var factory = new ChannelFactory<IService>(SuppliedEndpointName);
factory.Open();
var proxy = factory.CreateChannel();
var result = proxy.SomeServiceMethod();

如果我通过这个方法basicHttpBinding它完美地工作。
第二个i交换到nettcp,我立即收到此错误:

  

异常:套接字连接已中止。这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的。本地套接字超时为'00:01:00'。

     

内部异常:远程主机强行关闭现有连接

     

错误代码:10054

请任何人帮助我,它让我发疯 我肯定安装了WCF HTTP激活和非HTTP激活功能 我已将我的绑定设置为不同端口上的HTTP和net.tcp 我已将启用的协议设置为IIS中的http,net.tcp 我已禁用防火墙。 我已经为.net 4.0运行了aspnet_regiis -i

HELP!


我终于发现将我的安全模式更改为传输可以解决问题 但是我的服务将其安全模式设置为none 那么为什么我的客户端只能使用安全模式传输?

1 个答案:

答案 0 :(得分:8)

netTcpBinding默认情况下使用签名和加密传输安全性。请尝试删除security元素(<security mode="None"/>)。


另外

低于8000的端口(绝对低于1024)通常不安全用于服务。尝试使用安全端口。

相关问题