"没有终结点在监听..."

9
我正在尝试运行一个简单的WCF服务...
我的WCF服务配置文件:
<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>

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

因此,当我尝试从wcf代理(IMyContract)调用方法时,出现以下错误:

没有侦听http://MyServer:8000/WS的终结点能够接受消息。这通常是由于地址或SOAP操作不正确所致。有关更多详细信息,请参见InnerException(如果存在)。

内部异常:

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

有人知道原因吗?

1个回答

11

在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应用程序托管在该站点内。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接