Skip to content
Advertisement

How to change namespace prefix in SOAP webservice request created with SOAPMessage?

When I create my SOAP request using the javax.xml.soap.SOAPMessage class, I get a namespace prefix in my XML like <SOAP-ENV:Envelope>.

Is there a simple way to change the namespace prefix to <soapenv:Envelope>?

Advertisement

Answer

The XML namespace prefix should not matter as long as you are calling a well behaved web service. So SOAP-ENV:, soapenv:, or whatever: are basically the same thing as long as they both refer to the same namespace.

With that being said, if you really need to do this for some reason, here is some minimally working code. I’m calling this service.

JavaScript

I’ve printed the request message before and after the transformation. The output is as follows (formatting not included :D):

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement