I have created a SOAPHandler at client side to log outgoing request to server & modify some elements using JAX-WS.
After I modified elements, I save the message:
try {
// modifying elements
SOAPBody body = soapMsg.getSOAPBody();
NodeList blst = body.getElementsByTagName("ns6:exportNsiItemRequest");
Node itm = blst.item(0);
Node itm2 = itm.getFirstChild();
Document doc = body.getOwnerDocument();
doc.adoptNode(nd);
itm.insertBefore(nd, itm2);
soapMsg.saveChanges();
log.info("XML saved!");
} catch (SOAPException e1) {
log.info("XML DOESN'T saved!");
e1.printStackTrace();
}
then I print the message:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
msg.writeTo(baos);
System.out.println(baos.toString(getMessageEncoding(msg)));
This is a part of printed message:
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-4cf24b6d-5c1a-4756-9657-3ba87c3af164">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
I use the Wireshark to see context of the actual soap message which goes to server.
And WHAT I SEE?? It is:
<ds:Signature
xmlns=""
Id="xmldsig-4cf24b6d-5c1a-4756-9657-3ba87c3af164"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod
Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
Why something modified my message and insert empty xlnms="" tag???