user3475113
user3475113

Reputation: 87

Errors calling web service, " more than one endpoint configuration for that contract" or "no endpoint listening"

i just had a problem adding webservice that its solved in this thread error on adding webservice

now i just have a problem by calling its method

this is my app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="sedardIPSoap" />
        </basicHttpBinding>
        <customBinding>
            <binding name="sedardIPSoap12">
                <textMessageEncoding messageVersion="Soap12" />
                <httpTransport />
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://service.proapp.ir/service/sedardIP.asmx"
            binding="basicHttpBinding" bindingConfiguration="sedardIPSoap"
            contract="sedardip_set.sedardIPSoap" name="sedardIPSoap" />
        <endpoint address="http://service.proapp.ir/service/sedardIP.asmx"
            binding="customBinding" bindingConfiguration="sedardIPSoap12"
            contract="sedardip_set.sedardIPSoap" name="sedardIPSoap12" />
    </client>
</system.serviceModel>

so when i try calling my function like this

sedardip_set.sedardIPSoapClient nm = new sedardip_set.sedardIPSoapClient();
nm.set_ip("x1", "x2", "x3");

it throws this exception

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

so i tried deleting one of the endpoints from app.config, after that it throws this exception

There was no endpoint listening at http://service.proapp.ir/service/sedardIP.asmx 
that could accept the message. This is often caused by an incorrect address or 
SOAP action. See InnerException, if present, for more details.

inner exception

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

i just run service on my visual studio (locally) and by deleting second endpoint its just worked ! so can anyone plz help me to get this working on http://service.proapp.ir/service/sedardIP.asmx plz??

Upvotes: 3

Views: 2918

Answers (1)

Him_Jalpert
Him_Jalpert

Reputation: 2516

Is there a reason you need to use a web reference? A service reference is the updated, newer way of doing things, but if you need to use the web reference for some reason then that's fine too.

If you go the service reference route you can specifically name the endpoint you wish to use, for example:

sedardip_set.sedardIPSoapClient nm = new sedardip_set.sedardIPSoapClient("sedardIPSoap12");
nm.set_ip("x1", "x2", "x3");

It may have a new name after setting up the service reference but you would just substitute the new name in place of the sedardIPSoap12.

Upvotes: 3

Related Questions