[jboss-user] [JBoss Web Services] - How to modify SOAP body in JBoss 6.1.0. final?
Martin Jondzic
do-not-reply at jboss.com
Fri Feb 3 12:51:07 EST 2012
Martin Jondzic [https://community.jboss.org/people/hordak83] created the discussion
"How to modify SOAP body in JBoss 6.1.0. final?"
To view the discussion, visit: https://community.jboss.org/message/714363#714363
--------------------------------------------------------------
I'm trying to modify SOAP body for an outbound ws client SOAP message, from an application which is deployed on JBoss 6.1.0. Final.
There is a registered HandlerResolver for that purpose, which has the following code:
public boolean handleMessage(SOAPMessageContext messagecontext) {
Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
try {
SOAPMessage soapMessage = messagecontext.getMessage();
SOAPBody soapBody = soapMessage.getSOAPBody();
Node firstChild = soapBody.getFirstChild();
String timeStamp = getTimestamp();
String signature = getSignature(firstChild.getLocalName(), timeStamp, secretBytes);
SOAPFactory factory = SOAPFactory.newInstance();
SOAPElement signatureElement = factory.createElement("Signature");
System.out.println(signature);
signatureElement.addTextNode(signature);
SOAPElement timestampElement = factory.createElement("Timestamp");
timestampElement.addTextNode(timeStamp);
firstChild.appendChild(signatureElement);
firstChild.appendChild(timestampElement);
} catch(SOAPException se) {
throw new RuntimeException("SOAPException was thrown.", se);
}
}
return true;
}
However, it throws this exception:
17:59:35,527 WARN [org.apache.cxf.jaxws.handler.HandlerChainInvoker] HANDLER_RAISED_RUNTIME_EXCEPTION: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(Unknown Source) [:1.6.0_27]
at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(Unknown Source) [:1.6.0_27]
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(Unknown Source) [:1.6.0_27]
for this line:
firstChild.appendChild(signatureElement);
This code worked fine with JBoss 5.1.0.
Any ideas?
Thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/714363#714363]
Start a new discussion in JBoss Web Services at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120203/923e8550/attachment.html
More information about the jboss-user
mailing list