Client Program unable to connect with Web server

122 views Asked by At

I have a web service application http://localhost:49804/Service1.asmx and I'm able to call methods using a C# application successfully.

Later I have hosted the same Web service on IIS (http://localhost/MyFirstWebService/Service1.asmx) and I'm able to use with Web page(http put/get).

Now I have updated web service reference to http://localhost/MyFirstWebService/Service1.asmx in my C# application. Now If I call same method I'm getting Exception:

An endpoint configuration section for contract 'ServiceReference1.Service1Soap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

I have googled for this issue and I realize I need to add a client and web bindings in my web.config file. So I have added below part, But that doesn't solve the problem.

  <system.serviceModel>
    <client>
    <endpoint address="http://192.168.1.3/MyFirstWebService/Service1.asmx" binding="basicHttpBinding"
              contract="ClassABC" bindingConfiguration ="httpBinding"
              name="BasicHttpBinding_IABC" />
  </client>
  </system.serviceModel> 

Looks like I missed binding here in my web server application ? Hw can I solve this problem, any reference or links to where I should start or any example application will be great help. Do I need to change anything in my Web Service or web.config file changes should be enough ?

1

There are 1 answers

3
Special Sauce On

If you have more than one binding inside <configuration><system.serviceModel><bindings>, then you need to pick one by name and pass it to the constructor of your web service client to eliminate the ambiguity.

For example:

var svcClientObj = new CustomWebSvcClient("BasicHttpBinding_ICustomWebSvc_OverHttp");