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