I use the generated webservice proxy classes from visual studio 2010 to access a web service from my .net 2.0 client.
This works all fine, but my problem is, that the webservice has a wsdl for the testsystem and a wsdl for the production system.
While the webservices are structurally completely identical, their xml namespaces are not.
In my code, I can set the service URL of the webservice and the communication works (I use a TraceExtension to dump the SOAP messages to log files), but when it comes to deserialization, I get an exception.
I think this is because I generated the proxy classes with the WSDL file from the test system and this added several attributes like this: [System.Xml.Serialization.SoapTypeAttribute(Namespace="testservice url here")]
I could of course copy my project and add a webreference to the production service, but this would duplicate my code and I would have to make any further changes in future in two project, which is error prone of course.
Here is a working response for calling the Login-method against the test system service:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://TEST_SERVER_NAME/ProjectService">
<SOAP-ENV:Body>
<ns1:loginResponse xmlns:ns1="http://TEST_SERVER_NAME/ProjectService">
<login_result xsi:type="tns:LoginResult">
<errorcode xsi:type="xsd:integer">0</errorcode>
<errortext xsi:type="xsd:string">Successfully logged in</errortext>
<logincode xsi:type="xsd:string">wF3N5vdPsueL0aYlp41i6B8VTZEJztqx</logincode>
</login_result>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
here is the same response from the production webservice:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://PRODUCTION_SERVER_NAME/ProjectService">
<SOAP-ENV:Body>
<ns1:loginResponse xmlns:ns1="http://TEST_SERVER_NAME/ProjectService">
<login_result xsi:type="tns:LoginResult">
<errorcode xsi:type="xsd:integer">0</errorcode>
<errortext xsi:type="xsd:string">Successfully logged in</errortext>
<logincode xsi:type="xsd:string">wOmdlZMkIXVL4H8uTGU69hgpNsK1Cz3Q</logincode>
</login_result>
</ns1:loginResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see, the two responses only differ in the xmlns:tns attribute, while the xmlns:ns1 attribute is always http://TEST_SERVER_NAME/ProjectService
(I guess this is coming from the generated proxy class with the WSDL of the test system).
The logincode is only an authentication token and will always be different, so that's ok.
Is there any other solution to this problem?