When you create the body elements or header elements of a SOAP message, you must use the Name object to specify a well-formed name for the element. You obtain a Name object by calling the method SOAPEnvelope.createName.
When you call this method, you can pass a local name as a parameter or you can specify a local name, prefix, and URI. For example, the following line of code defines a name object bodyName.
Name bodyName = MyEnvelope.createName("TradePrice", "GetLTP","http://foo.eztrade.com");
This would be equivalent to the namespace declaration:
<GetLTP:TradePrice xmlns:GetLTP= "http://foo.eztrade.com">
The following code shows how you create a name and associate it with a SOAPBody element. Note the use and placement of the createName method.
SoapBody body = envelope.getBody();//get body from envelope Name bodyName = envelope.createName("TradePrice", "GetLTP", "http://foo.eztrade.com"); SOAPBodyElement gltp = body.addBodyElement(bodyName);