To set a namespace as the default namespace, simply use the empty string (""
) as prefix name:
SOAPElement GetNGPList =
soapBody.addChildElement("GetNGPList", "", "http://www.sigvalue.com/acc");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The code above will apply xmlns="http://www.sigvalue.com/acc"
to GetNGPList
.
Your code, adapted:
// SOAP Body
SOAPBody soapBody = envelope.getBody();
SOAPElement GetNGPList =
soapBody.addChildElement("GetNGPList", "", "http://www.sigvalue.com/acc");
SOAPElement UserData = GetNGPList.addChildElement("UserData");
...
As usual, when you omit the namespace prefix declaration in addChildElement()
, the child inherits its namespace from its parent.
The code above will generate what you needed:
<SOAP-ENV:Envelope 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">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<GetNGPList xmlns="http://www.sigvalue.com/acc">
<UserData>
<senderId>string</senderId>
...