【问题标题】:Problem with having 2 endpoints : wsHttpBinding and netTCPBinding有 2 个端点的问题:wsHttpBinding 和 netTCPBinding
【发布时间】:2011-07-26 16:39:26
【问题描述】:

我正在学习 WCF,并首先使用 wsHttpBinding 开发了一项服务,并将其托管在 IIS7 (win7) 上,并从 Windows 客户端应用程序中使用了该服务。它工作正常(使用 WCF 服务 DLL 方法)

我尝试有两个端点并添加了netTCpBinding。我遇到错误

{TransportManager 未能使用 NetTcpPortSharing 服务:无法启动该服务,因为它是 禁用。

我已经启动了所需的服务,甚至重新启动了我的机器。在“服务”中,这 2 个服务显示为已启动。我已经在 IIS 中启用了所需的 tcpnetbinding 设置,正如许多博客和 msdn 所告知的那样。

我的客户端应用配置是这样的:

 <configuration>    
    <system.serviceModel>
        <bindings />
        <client>
           <endpoint name="httpEndpoint"
               address="http://MachineName:8000/FLOW5WCFService.svc"
               binding="wsHttpBinding"
               contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
           <endpoint name="tcpEndpoint"
               address="net.tcp://MachineName:8082/FLOW5WCFService.svc"
               binding="netTcpBinding"
               contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
        </client>
    </system.serviceModel>
</configuration>

服务web.config:

<configuration>
   <system.serviceModel>
      <bindings>
         <netTcpBinding>
              <binding name="tcpBinding" 
                  portSharingEnabled="true"
                  closeTimeout="00:10:00" openTimeout="00:10:00"
                  receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="true"
                  hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
                  maxReceivedMessageSize="2147483647">
                  <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
                      maxArrayLength="2147483647" maxBytesPerRead="4096" 
                      maxNameTableCharCount="320000" />
              </binding>
         </netTcpBinding>
      </bindings>
      <services>
          <service behaviorConfiguration="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour" 
                   name="FLOW5ServiceDLL.FLOW5WCFService">
             <endpoint 
                 address="" 
                 binding="wsHttpBinding" 
                 contract="FLOW5ServiceDLL.IFLOW5WCFService">
                 <identity>
                     <dns value="localhost" />
                 </identity>
             </endpoint>
             <endpoint
                 binding="netTcpBinding"
                 bindingConfiguration="tcpBinding"
                 contract="FLOW5ServiceDLL.IFLOW5WCFService"/>
            <endpoint 
                address="mex" 
                binding="mexHttpBinding" 
                contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                     <add baseAddress="http://localhost:8000/" />
                     <add baseAddress="net.tcp://localhost:8082" />
                </baseAddresses>
            </host>
        </service>
   </services>
   <behaviors>
       <serviceBehaviors>
            <behavior name="FLOW5ServiceDLL.FLOW5WCFServiceBehaviour">
               <serviceMetadata httpGetEnabled="false" />
               <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
       </serviceBehaviors>
   </behaviors>
</system.serviceModel>
<system.web>
    <compilation debug="false" />
</system.web>
</configuration>

我正在我的客户端代码中创建一个频道,如下所示

ChannelFactory<IFLOW5WCFService> protocolFactory 
      = new ChannelFactory<IFLOW5WCFService>("tcpEndpoint");
l_oFLOW5Service = protocolFactory.CreateChannel();

如果我的配置错误或者我需要做任何其他设置,谁能告诉我?如果需要更多信息,请告诉我

提前致谢

【问题讨论】:

  • 还有人需要更多信息吗?没有答案!! ..请让我知道,以防有人发现更多事情要做..

标签: c# .net wcf wcf-binding


【解决方案1】:

我看到两件事:

1) 在您服务器的web.config 中,您的 netTcp 端点没有地址。如果您想让 netTcp 端点监听 net.Tcp 的默认基地址,我仍然会始终将 address="" 放入我的端点:

<endpoint
    address=""
    binding="netTcpBinding"
    bindingConfiguration="tcpBinding"
    contract="FLOW5ServiceDLL.IFLOW5WCFService"/>

2) 在您的客户端中,您没有定义任何netTcpBinding 配置,而在服务器端,您可以定义。我现在看不到任何关键设置 - 但为了安全起见,我建议您尝试在客户端的配置中使用相同的 netTcpBinding 配置,并在客户端的 tcpEndpoint 中使用它,看看是否可以有什么不同。

如果没有任何效果:为什么不尝试禁用/关闭服务器端的 NetTcp 端口共享?在您的示例中,我真的没有看到任何需要这个 - 只要你真的不需要它,就试着在没有它的情况下相处。

【讨论】:

  • 1)我之前添加了地址,它仍然没有工作...... 2)嗯..我读了很多,我的客户端配置中不需要绑定配置..但正如你所说,你永远不知道,我会试试的。我认为使用 netTcpBinding 默认需要 NetTcp 端口共享服务,无论如何我都会将其关闭并检查..感谢您正确编辑我的问题..
猜你喜欢
  • 2010-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多