I am just creating some small C# programs to access third party webservices. There are different services, but the structure is pretty similar - especially in the naming convention for the binding
WSDL for Service 'QueryCustomerIn'
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://sap.com/xi/A1S/Global" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ...>
...
<wsdl:binding name="binding_SOAP12" type="tns:QueryCustomerIn">
...
</wsdl:binding>
<wsdl:service name="service">
<wsdl:port name="binding_SOAP12" binding="tns:binding_SOAP12">
<wsoap12:address location="https://my123456.sapbydesign.com/sap/bc/srt/scs/sap/querycustomerin1?sap-vhost=my123456.sapbydesign.com"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
WSDL for 'QueryOrganisationalCentreIn'
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://sap.com/xi/A1S/Global" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ...>
...
<wsdl:binding name="binding_SOAP12" type="tns:QueryOrganisationalCentreIn">
...
</wsdl:binding>
<wsdl:service name="service">
<wsdl:port name="binding_SOAP12" binding="tns:binding_SOAP12">
<wsoap12:address location="https://my123456.sapbydesign.com/sap/bc/srt/scs/sap/queryorganisationalcentrein?sap-vhost=my123456.sapbydesign.com"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
As you see, both services name their endpoints "binding_SOAP12" but each points to a different location.
When I create the client in Visual Studio 2010 with "Add service reference", I can access the service the following way:
QueryOrganisationalCentreInClient client = new QueryOrganisationalCentreInClient("binding_SOAP12");
But when I add the second service, the similar request for the second service
QueryCustomerInClient client = new QueryCustomerInClient("binding_SOAP12");
fails with a System.InvalidOperationException (The endpoint could not be found or the endpointcontract is not valid).
I tested some things and found out the following:
- The first client (Organisational...) still works normally like before the second service has been added
- If I create a new project and just add the second service (Customer...) the same way (but without any other service) it works.
- When I edit the (provided) WSDL-file for the Customer...Service and change the name of the endpoint to a different name, it also works in the project together with the first service (Organisational...)
It looks like VisualStudio 2010 cannot deal with equally named endpoints in different service contracts in the same project. But as I am not in the position to dictate the naming of the endpoints: How can I use both services in my project despite this problem?
Thanks in advance,
Frank