gpt4 book ai didi

防火墙后面的 wsDualHttpBinding 和 netTcpBinding 的 WCF 问题

转载 作者:行者123 更新时间:2023-12-04 05:49:04 25 4
gpt4 key购买 nike

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

由于wsDualHttpBinding的性质如果客户端在自己的防火墙后面,这显然无法工作。很自然,netTcpBinding想到应该解决双向问题。但奇怪的是,当服务配置 XML 更新为包含 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>

最佳答案

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

关于防火墙后面的 wsDualHttpBinding 和 netTcpBinding 的 WCF 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10311446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com