【问题标题】:calling WCF client function doesn't work on IIS调用 WCF 客户端函数在 IIS 上不起作用
【发布时间】:2011-08-23 15:14:36
【问题描述】:

我使用 WCF 发现创建了一项服务。将其部署在特定端口上时一切正常(使用 VS2010 调试),但是当我尝试将其部署到 IIS 时,它找到了服务但无法运行任何方法。

这是代码:

 DiscoveryClient discoverclient = new DiscoveryClient(new UdpDiscoveryEndpoint());
 FindResponse response = discoverclient.Find(new FindCriteria(typeof(IService)));
 EndpointAddress address = response.Endpoints[0].Address;
 ServiceClient client = new ServiceClient(new BasicHttpBinding(), address);
 Console.WriteLine(client.getMsg()); //some test function
 Console.ReadKey();

当我尝试运行client.getMsg() 方法时,出现以下错误:

EndpointNotFoundException:
没有端点监听 http://computerName.domain/services/Service.svc 可以接受 信息。这通常是由不正确的地址或 SOAP 操作引起的。 有关详细信息,请参阅 InnerException(如果存在)。

但我得到了地址,这意味着它找到了。如果我使用调试部署器(而不是 iis),我会在 http://localhost:port/services/Service.svc 中找到它,它运行得非常好。我怎样才能毫无问题地将它部署到 iis?

操作系统:win7 64位

配置文件:

<services>
  <service behaviorConfiguration="RemoteDeploy.Service1Behavior"
    name="RemoteDeploy.Service">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
      contract="RemoteDeploy.IService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint name="udpDiscoveryEpt" kind="udpDiscoveryEndpoint" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>

</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="RemoteDeploy.Service1Behavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceDiscovery>

        </serviceDiscovery>
    </behavior>
  </serviceBehaviors>
</behaviors>

【问题讨论】:

  • 也许您需要将 svc 映射添加到 IIS? (ServiceModelReg.exe -i)
  • 能否请您发布您的 web.config 文件,至少在您配置端点的位置。多次使用 WCF 服务时,所有问题都与其配置有关。

标签: c# wcf web-services discovery service-discovery


【解决方案1】:

首先尝试在您的浏览器中获取http://computerName.domain/services/Service.svc - 您收到错误或服务描述..

【讨论】:

  • 在浏览器中转到该链接也不起作用,但转到:localhost/services/Service.svc 确实有效。 findCriteria 给了我错误的地址(给了我完整的计算机位置)
  • 我在具有计算机域名和 localhost 的浏览器中得到相同的结果 - 作为 URI 的一部分 - 您是否肯定 computerName.domain 是正确的,或者它可能只是片段?
猜你喜欢
  • 1970-01-01
  • 2011-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多