I am trying to assemble a SOAP request using SAAJ.
The original SOAP request looks like this
(...)
<soapenv:Body>
<methodName xmlns="http://xyz.abc/asdfgh">
(...)
</methodName>
</soapenv:Body>
Using SAAJ, my code would look like
SOAPBody soapBody = envelope.getBody();
SOAPElement req= soapBody.addChildElement("methodName");
req.addNamespaceDeclaration("", "http://xyz.abc/asdfgh");
The problem, of course, is that the namespace prefix can't be empty or null.
So how can I generate the SOAP request namespace without a prefix in this case?
To add the methodName
element with a default namespace, change
SOAPElement req= soapBody.addChildElement("methodName");
to
SOAPElement req= soapBody.addChildElement("methodName","","http://xyz.abc/asdfgh");