Search code examples
c#asp.netweb-serviceswcfwsdl

There was no endpoint listening at ".svc" that could accept the message


I get an exception when connecting to a WCF web service.

I add this web service as Service Reference in my project.

The address is http://192.168.16.91:8092/ws_merchants.svc and wsdl address http://192.168.16.91:8092/ws_merchants.svc?wsdl.

In the app.config, I have this binding config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_Iws_Merchants" />
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint name="BasicHttpBinding" 
            address="http://192.168.16.91:8092/ws_merchants.svc"
            binding="basicHttpBinding"  
            bindingConfiguration="BasicHttpBinding_Iws_Merchants"
            contract="ServiceReferenceSahand.Iws_merchants" />
    </client>
</system.serviceModel>

My code to use this service :

private bool GetToken()
{
    try
    {
        Iws_merchantsClient def = new Iws_merchantsClient();
        var res = def.get_Token("user", "pass");
    }
    catch (Exception ex)
    {
        return false;
    }
}

I get this exception :

There was no endpoint listening at http://192.168.16.91:8092/ws_merchants.svc that could accept the message.
This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.

and in the inner exception :

The remote server returned an error: (404) Not Found.

What is not found, when I add this methods from wsdl as service reference?


Solution

  • i guess something is wrong with your wsdl file. you can check your client config file and see if the endpoint address is right or not. its little tricky. and can cause by so many reasons. i suggest to you start tracing the problem with wcf test client. let me know if you can find anything.