【问题标题】:"There was no endpoint listening at..."“没有端点在监听……”
【发布时间】:2012-03-19 18:21:24
【问题描述】:

我正在尝试运行一个简单的 WCF 服务...

我的 Wcf 服务 .config:

<system.serviceModel>
<services>
  <service name ="WebService.Receptor">
    <endpoint
      address = "http://MyServer:8000/WS"
      binding = "wsHttpBinding"
      contract = "IMyContract"
    />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

我的 Windows 服务 .config:

<system.serviceModel>
<client>
  <endpoint 
    name = "Receptor"
    address = "http://MyServer:8000/WS"
    binding = "wsHttpBinding"
    contract = "IMyContract"
    />
</client>
</system.serviceModel>

Obs:Wcf 服务在 Windows 7 上的 IIS 7.5 下运行。

所以,当我尝试从 wcf 代理 (IMyContract) 调用方法时,我收到了这个错误:

http://MyServer:8000/WS 上没有可以接受消息的端点监听。这通常是由不正确的地址或 SOAP 操作引起的。有关详细信息,请参阅 InnerException(如果存在)。

内部异常:

{“无法连接到远程服务器”}

有人知道为什么吗?

【问题讨论】:

    标签: .net wcf iis


    【解决方案1】:

    当您在 IIS 中托管 WCF 服务时,您无需在地址中指定绝对 url。您应该使用 .svc 文件的相对 URL。基本 url 将由托管它的网站确定。

    <service name="WebService.Receptor">
        <endpoint
            address="/WS.svc"
            binding="wsHttpBinding"
            contract="IMyContract"
         />
    </service>
    

    在客户端上,根据您的 IIS 的配置方式,您显然应该指定完整地址:

    <client>
        <endpoint 
            name="Receptor"
            address="http://MyServer:8000/WS.svc"
            binding="wsHttpBinding"
            contract="IMyContract"
        />
    </client>
    

    这假定您已在 IIS 中配置了一个侦听 8000 端口的站点,并且您已在该站点内托管了您的 WCF 应用程序。

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多