【发布时间】:2012-04-25 07:45:19
【问题描述】:
我有一个独立的 WCF 服务在防火墙后面的服务器上运行。它目前使用wsDualHttpBinding,因为该服务使用回调。客户端在 LAN 环境中工作正常。我们已打开防火墙以允许自定义端口上的流量,因此现在可以从外部 LAN 发现服务。
由于wsDualHttpBinding 的性质,如果客户端位于自己的防火墙后面,这显然无法工作。所以很自然地,netTcpBinding 浮现在脑海中,它应该可以解决双向问题。但奇怪的是,当服务配置 XML 更新为在 same 端口上包含 netTcpBinding(和/或排除 wsDualHttpBinding)时,甚至服务发现也不再起作用。
我想知道我是否还缺少其他任何东西。我已遵循 How to: Use netTcpBinding with Windows Authentication and Message Security in WCF Calling from Windows Forms 和 Windows 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>
【问题讨论】:
-
服务发现到底是什么意思?您是否使用 WCF 4 中的 WS-Discovery 机制?
-
不,我可能使用了错误的术语。对于“发现”,我的意思是添加服务引用是成功的。
-
显示整个服务配置。
-
如果你想暴露两个基地址,你必须为 http 和 net.tcp 使用不同的端口。
-
好的,谢谢。我真的给你发了一个旧的配置。但是考虑
wsDualHttpBinding及其基地址被完全注释掉(或删除)所以只剩下netTcpBinding的场景。为什么那行不通?
标签: wcf nettcpbinding wshttpbinding