【发布时间】:2011-10-27 09:26:58
【问题描述】:
这是我的 App.config:
<?xml version="1.0"?>
<configuration>
<runtime>
</runtime>
<system.serviceModel>
<diagnostics performanceCounters="Default" />
<bindings />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<endpointBehaviors>
<behavior name="CrossDomainServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AService.AServBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyService.MyServiceBehavior" name="MyService.MyServ">
<endpoint address="MyService" behaviorConfiguration="" binding="netTcpBinding" contract="AService.IAServ" isSystemEndpoint="false" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
如您所见,没有什么特别之处。我只想创建具有 tcp 绑定和传输元数据信息能力的简单服务。我使用basicHttpBinding 成功地使用了同一个,并且一切正常。
下面是使用基地址创建服务实例的代码:
Console.WriteLine("net.tcp://" + _bindAddress + "/");
ServiceHost myserviceHost = new ServiceHost(typeof(MyService), new Uri(String.Concat("net.tcp://", _bindAddress, "/")));
myserviceHost.Open();
_bindAddress 是来自自定义服务配置 XML 文件的字符串。我正在尝试将服务绑定到 IP 地址172.19.0.102:8733 的内部网络接口。然后我尝试使用 WcfTestClient 从服务机器上的地址127.0.0.1:8733 获取服务元数据,一切都很好。但是后来我尝试通过 Internet 在目标远程计算机上获取服务的元数据,我得到了TCP error with code 10051。
我的目标是让服务正常工作并通过 Internet 为任何客户端发布元数据。防火墙和其他网络东西没有问题。似乎我需要一些配置编辑以允许服务与所有人共享元数据。
提前致谢!
后编辑:
这是我的尝试:
1) 服务配置为绑定172.19.0.102:8733。
A. WCF 测试客户端尝试从地址net.tcp://127.0.0.1:8733/ 获取托管计算机上的元数据失败,出现TCP error code 10061。
B. 在同一台机器上,WCF 客户端尝试从net.tcp://172.19.0.102:8733 获取元数据,并且工作正常。
C. WCF 测试客户端尝试从地址net.tcp://192.168.1.2:8733/(它是服务的机器 IP 地址)获取 LAN 中另一台机器上的元数据,给出错误TCP error code 10061。
【问题讨论】:
标签: c# .net wcf networking tcp