首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

org.w3c.dom.DOMException:WRONG_DOCUMENT_ERR,该如何解决

2013-07-16 
org.w3c.dom.DOMException:WRONG_DOCUMENT_ERRorg.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is

org.w3c.dom.DOMException:WRONG_DOCUMENT_ERR
org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

Document doc = DocumentBuilderFactory.newInstance()
                           .newDocumentBuilder()
                           .parse(new ByteArrayInputStream(out.toByteArray()));

SOAPBody body = msg.getSOAPBody();
                   Node port = body.getChildNodes().item(0);
            
port.appendChild(doc.getFirstChild().getFirstChild());

appendChild,添加节点的时候提示A node is used in a different document than the one that created it.

请问要怎么办?谢谢!

[解决办法]
另外一个Document不能像当前的Document 添加节点

Document respDoc = body.getOwnerDocument(); 
port.appendChild(respDoc.adoptNode(doc.getFirstChild()));

热点排行