Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"There was no endpoint listening at..."

Tags:

.net

iis

wcf

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

My Wcf Service .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:

<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.

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

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.

The inner exception:

{"Unable to connect to the remote server"}

Anyone knows why?

like image 366
Vinicius Ottoni Avatar asked Mar 19 '12 18:03

Vinicius Ottoni


1 Answers

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.

<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:

<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.

like image 94
Darin Dimitrov Avatar answered Nov 15 '22 20:11

Darin Dimitrov