SOAPbody.addDocument(doc)出现NAMESPACE_ERR 错误

org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.



DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
                      

 docFactory.setNamespaceAware(true);   //添加这一句就不会出错了
                      

 DocumentBuilder builder = docFactory .newDocumentBuilder();
                       

Document doc = builder.parse(new ByteArrayInputStream(out.toByteArray()));
                      

body.addDocument(doc);






你可能感兴趣的:(webservice)