防火墙后wsDualHttpBinding和netTcpBinding的WCF问题

防火墙后wsDualHttpBinding和netTcpBinding的WCF问题,wcf,nettcpbinding,wshttpbinding,Wcf,Nettcpbinding,Wshttpbinding,我有一个独立的WCF服务在防火墙后面的服务器上运行。它当前使用wsDualHttpBinding,因为服务使用回调。客户端在局域网环境中工作正常。我们已经打开了防火墙,允许在自定义端口上进行通信,因此服务的发现现在可以从LAN外部进行 由于wsDualHttpBinding的性质,如果客户端位于自己的防火墙后面,那么这显然无法工作。因此,很自然地,netTcpBinding会出现在我的脑海中,这应该可以解决双向问题。但奇怪的是,当服务配置XML更新为在相同的端口上包含netTcpBinding(

我有一个独立的WCF服务在防火墙后面的服务器上运行。它当前使用
wsDualHttpBinding
,因为服务使用回调。客户端在局域网环境中工作正常。我们已经打开了防火墙,允许在自定义端口上进行通信,因此服务的发现现在可以从LAN外部进行

由于wsDualHttpBinding的性质,如果客户端位于自己的防火墙后面,那么这显然无法工作。因此,很自然地,
netTcpBinding
会出现在我的脑海中,这应该可以解决双向问题。但奇怪的是,当服务配置XML更新为在相同的端口上包含
netTcpBinding
(和/或排除
wsDualHttpBinding
)时,甚至服务发现也不再起作用

我想知道我是否还遗漏了什么。我遵循了来自和来自的关于配置的确切建议

配置:

<system.serviceModel>
  <bindings>
    <netTcpBinding>
      <binding name="NetTcpBindingEndpointConfig">
        <security mode="Message" />
      </binding>
    </netTcpBinding>
  </bindings>
  <services>
    <service name="Service1.Service1.Service">
      <endpoint address="Service1" binding="wsDualHttpBinding" contract="Service1.IService1">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      <endpoint address="" binding="netTcpBinding"
                 bindingConfiguration="NetTcpBindingEndpointConfig"
                 name="NetTcpBindingEndpoint" contract="Service1.IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <host>
        <baseAddresses>
          <add baseAddress="http://localhost:9999/Service1.Service1/"/>
          <add baseAddress="net.tcp://localhost:9999/Service1.Service1/" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, 
        set the value below to false and remove the metadata endpoint above before deployment -->
        <serviceMetadata httpGetEnabled="True"/>
        <!-- To receive exception details in faults for debugging purposes, 
        set the value below to true.  Set to false before deployment 
        to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="True"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

如果您只能使用单端口,并且必须使用netTcpBinding,请尝试以以下方式配置您的服务:

<system.serviceModel>
  <bindings>
    <netTcpBinding>
      <binding name="NetTcpBindingEndpointConfig">
        <security mode="Message" />
      </binding>
    </netTcpBinding>
  </bindings>
  <services>
    <service name="Service1.Service1.Service">
      <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      <endpoint address="" binding="netTcpBinding"
                 bindingConfiguration="NetTcpBindingEndpointConfig"
                 name="NetTcpBindingEndpoint" contract="Service1.IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:9999/Service1.Service1/" />
        </baseAddresses>
      </host>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <serviceMetadata httpGetEnabled="False"/>
        <serviceDebug includeExceptionDetailInFaults="True"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

您所说的服务发现到底是什么意思?您是否使用WCF 4中的WS-Discovery机制?不,我可能使用了错误的术语。对于“发现”,我的意思是添加服务引用是成功的。显示服务的整个配置。如果要公开两个基本地址,则必须为http和net.tcp使用不同的端口。好的,谢谢。我真的给你发了一个旧的配置。但是考虑下面的场景:代码> WSDUAL HTTPBBION/CODE >及其基本地址完全注释(或删除),因此只保留代码> NETTCPB绑定< /代码>。为什么这不起作用呢?让我补充一点,我的特定场景中有多个服务托管在一个集群中,因此显然存在端口冲突。幸运的是,我找到了帮助我认识到我还需要在我的
绑定上使用
portSharingEnabled=“true”
。我还将
mex
更改为使用相同的共享
netTcpBinding
net.tcp://localhost:9999/Service1.Service1/mex