2

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

如果客户端位于其自己的防火墙后面,则由于其性质wsDualHttpBinding显然无法正常工作。所以很自然地,netTcpBinding想到哪个应该解决双向问题。但奇怪的是,当服务配置 XML 更新为包含netTcpBinding同一端口(和/或排除wsDualHttpBinding)上时,甚至服务发现也不再起作用。

我想知道我是否还有其他遗漏。我已遵循如何配置的确切建议:使用 netTcpBinding with Windows Authentication and Message Security in WCF Calling from Windows FormsWindows Communication Foundation QuickStart - Multiple Binding VS2010

配置:

<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>
4

1 回答 1

3

如果您只能使用单个端口并且必须使用 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>

添加服务引用时,请尝试使用此地址:

net.tcp://localhost:9999/Service1.Service1/mex
于 2012-04-25T15:20:37.063 回答