“没有终点听......”

时间:2022-04-25 16:49:57

I'm trying to run a simple WCF Service...

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

My Wcf Service .config:

我的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" />

My Windows Service .config:

我的Windows服务.config:

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

Obs: The Wcf Service is running under IIS 7.5 on Windows 7.

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

So, when i try to call a method from the wcf proxy (IMyContract) i got this error:

所以,当我尝试从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.

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

The inner exception:

内在的例外:

{"Unable to connect to the remote server"}

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

Anyone knows why?

谁知道为什么?

1 个解决方案

#1


11  

When you host a WCF service in IIS you don't specify an absolute url in the address. You should use a relative url to the .svc file. The base url will be determined by the web site where it is hosted.

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

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

and on the client, depending on how your IIS is configured you should obviously specify the full address:

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

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

This assumes that you have configured a site in IIS that listens on the 8000 port and that you have hosted your WCF application inside this site.

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

#1


11  

When you host a WCF service in IIS you don't specify an absolute url in the address. You should use a relative url to the .svc file. The base url will be determined by the web site where it is hosted.

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

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

and on the client, depending on how your IIS is configured you should obviously specify the full address:

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

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

This assumes that you have configured a site in IIS that listens on the 8000 port and that you have hosted your WCF application inside this site.

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