We’ve built a webservice with Spring-WS, and are trying to access it from a C# .NET client. the service works OK with all the tests we’ve done from SoapUI and other java clients, but gets stuck in .NET.
It seems this is a problem with namespaces.
For example, this request works, when the namespace is declared only in the envelope tag, and no element has namespace or prefix in it:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://mycompany.org/schemas">
<soapenv:Header/>
<soapenv:Body>
<authenticationRequest>
<username>user</username>
<password>password</password>
</authenticationRequest>
</soapenv:Body>
</soapenv:Envelope>
However, this seemingly equivalent request does NOT work:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://mycompany.org/schemas">
<soapenv:Header/>
<soapenv:Body>
<authenticationRequest xmlns="http://mycompany.org/schemas">
<username>user</username>
<password>password</password>
</authenticationRequest>
</soapenv:Body>
</soapenv:Envelope>
Notice that in this case, the namespace is declared again in authenticationRequest element.
The error given is that the request does not validate against the XML schema, complaining that the ‘username’ element is not defined.
Unfortunately, when adding a service reference (and also a web reference) in .NET, the code generated by wsdl.exe always creates the request in the second case.
Could someone, please, explain why these two pieces of XML are not equivalent, and how we could, in the C# client…
– remove the second namespace declaration?
– or add a namespace prefix to every element in the request?
– or add a namespace declaration without prefix to each element?
We’ve been trying for hours 🙁
Thanks!
I’ve had similar problems with accessing a Java WS from .NET client. I havent found an elegant solution to the problem, but I did solve it by changing the outgoing/incoming SOAP messages with a SoapExtension:
Implement a SoapExtensionAttribute, like this:
Implement a SoapExtension, like this: