.net - "There was no endpoint listening at..."

标签 .net wcf iis

我正在尝试运行一个简单的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>

观察:Wcf服务在Windows 7的IIS 7.5下运行。

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

There was no endpoint listening at http://MyServer:8000/WS that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.



内部异常:

{"Unable to connect to the remote server"}



有人知道为什么吗?

最佳答案

当您在IIS中托管WCF服务时,您无需在地址中指定绝对URL。您应该使用相对URL到.svc文件。基本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应用程序。

关于.net - "There was no endpoint listening at...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9775667/

相关文章:

c# - 使用 .NET 和 Powershell 远程推送 PFX 证书和私钥

c# - 使用 shellExecute 运行 c# 控制台应用程序

asp.net - 将我的 Web.Config 应用程序设置存储在单独的文件中时,是否总是需要 IIsreset?

IIS服务器版本兼容性

c# - DrawImage 无法正确定位切片图像

.net - 批量上传到 Azure 中的 blob

c# - 发送文件上传到WCF

c# - WCF 到 WCF 通过 MSMQ 请求和响应

java - 来自 Google App Engine/Google Web 工具包的 Web 服务?

iis - 调试 SignalR 挂起