WCF服务与同一台计算机上的客户端一起使用,但如果我将客户端移动到同一网络上的另一台计算机则不行

时间:2012-09-20 08:53:36

标签: c# wcf endpoint

我的计算机上运行了WCF服务。此服务在system.servicemodel:

下的app.config文件中具有以下配置
<client />
<services>
  <service name="AnchorWcfService.AnchorService" behaviorConfiguration="serviceBehavior">
    <endpoint address="AnchorService" contract="AnchorWcfService.IAnchorService" binding="wsHttpBinding" bindingConfiguration="TransportSecurity" />
    <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding" /> 
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="TransportSecurity" maxReceivedMessageSize="5000000">
      <readerQuotas maxStringContentLength="5000000" maxDepth="128" maxArrayLength="5000000" />
      <security mode="None">
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="serviceBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

从我的代码中,我像这样启动主机:

serviceHost = new ServiceHost(typeof (AnchorService), new Uri("http://192.168.0.16:8080/"));
serviceHost.Open();

本地计算机的IP地址当然是192.168.0.16。

此外,我还从代码中添加了以下端点以启用WS-Discovery:

var discoveryBehavior = new ServiceDiscoveryBehavior();
discoveryBehavior.AnnouncementEndpoints.Add(new UdpAnnouncementEndpoint());
serviceHost.Description.Behaviors.Add(discoveryBehavior);
serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint());

现在,从本地机器发现和连接工作就好了。我还可以使用wcftestclient按预期连接到服务并输入网址http://192.168.0.16:8080http://localhost:8080。所以到目前为止一切顺利。

然后我将我的客户端移动到另一台机器并启动它。

该发现工作正常,它返回服务器计算机上端点的url,但在尝试连接时表示找不到端点。

另外,在wcftestclient中。我无法连接,我同时处理了http://192.168.0.16:8080http://192.168.0.16:8080/AnchorService

因此,发现端点似乎是从远程计算机工作,而不是服务端点?

知道我哪里错了吗?

0 个答案:

没有答案
相关问题