views:

198

answers:

2

NB-6.8 jdk-1.6.14 WSS4j-1.5.8 ,OpenSAML-2.3.0 I try to modify WSS4J-1.5.8 to operate SAML 2.0, and I could not insert a generated assertion to existing SOAP Header, the code like this:

Assertion assertion = createAssertion("some subject", "some issuer");

    Document doc = docBuilder.parse("request.xml");

    Element parent = doc.getDocumentElement();

    Node node = parent.getElementsByTagName("soapenv:Header");
    node.appendChild(assertion.getDOM());

Error : WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

but in wss4j, some functions like insertSecurityHeader do so(appendChild or inserBefore) ,too. They do work, why it's wrong in my code? what I miss.

A: 

I recently ran into a similar issue. In my case it was because of some missing namespaces.

JST
A: 

Actually, I ran into problems using importNode (NAMESPACE_ERR), which could be resolved using adoptNode instead.

ralph