I’m using the Spring WS version 1.5.8. My response looks like this:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
However, my client (whom I integrate with) requires that I will add more namespace declerations in order for the parsing to succeed:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
How can I do it?
You probably don’t need me to tell you that any SOAP client that requires certain namespace declarations to be present, when those namespaces are not used in the document, is broken. So I won’t mention that.
However, if you do want to mutate the response like that, you can use an
EndpointInterceptor, specifically aSoapEndpointInterceptor. You can wire up endpoint interceptors as described here.Your custom interceptor can implement the
handleResponsemethod, castingmessageContext.getResponse()toSoapMessageand adding whatever you need to that:Adding such low-level namespace declarations may have side-effects, though, so tread carefully.