2012-03-19 78 views
9

我想运行一个简单的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:The Wcf Serv冰IIS 7.5在Windows上运行7

所以,当我尝试调用从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"}

任何人都知道为什么?

回答

11

当您在IIS中托管WCF服务时,您不会在地址中指定绝对URL。您应该使用.svc文件的相对网址。基础网址将由其托管的网站决定。

<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应用程序。