This is related to a previous question. I've pulled out the main problem as I've updated much of the code but I still have an issue. How can I have a custom SOAPHandler class add a new element to a SOAP message? I need to add a username and password to the message. If I use:
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage msg = context.getMessage();
SOAPPart part = msg.getSOAPPart();
SOAPEnvelope envelope = part.getEnvelope();
.... //additional header information
SOAPElement element.addChildElement("Username", "sse");
element.addTextNode("user1");
element.addChildElement("Password", "sse");
element.addTextNode("1234");
}
I end up with this where the tags are closed and the values aren't enclosed:
<sse:Username/>user1
<sse:Password/>1234
I want to end up with the username and password formatted like this:
<sse:Username>user1</sse:Username>
<sse:Password>1234</sse:Password>
How can I get the values (user1 and 1234) enclosed in the element?