Monday, November 26, 2012

WCF : Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy

There are many cases of getting this error when you call WCF service from your client.

Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.


You can specify mismatched bindings between server config and client config. WCF trace log typcally can show more details. One of the cases I experienced was when I set invalid endpoint setting. When hosting WCF service in IIS, I incorrectly set an endpoint address. I was able to see WSDL by using http://localhost:8088/SimpleService.svc but when trying to call actual WCF service from WCFTestClient (VS tool), I got the excepton.
It turned out I specified http://localhost:8088/ in address attribute where I was supposed to specify http://localhost:8088/SimpleService.svc. (Note: we can use routing table to avoid specifying .svc file, but I did not use routing table for this case. Please see this post for this sample)
  <system.serviceModel>    
    <services>      
      <service name="SimpleWcfService.SimpleService" 
        <endpoint address="http://localhost:8088/" binding="wsHttpBinding"
                  contract="SimpleWcfService.ISimpleService"></endpoint>       
      </service>
    </services>
  </system.serviceModel>
By changing address attribute to .svc url, it all worked fine.

2 comments:

  1. hi...alex............
    i am having same problem... i am using wcf webservices
    what to do

    ReplyDelete
  2. hunk, first of all you might want to check endpoint config in both web.config (in case you use IIS hosting) and your client config. Generally both configs should match.

    ReplyDelete