Is there a methode to linarize a Document?

Posted by M.R. on Stack Overflow See other posts from Stack Overflow or by M.R.
Published on 2010-06-09T08:32:58Z Indexed on 2010/06/09 8:52 UTC
Read the original article Hit count: 291

Filed under:
|

A webservice response with a message which is not linarized. This produces a problem, when trying to access a (as an example) the root element with getSOAPBody().getFirstChlid(). In a linarized document this call would return the first element inside the the body. If the message is not properly formated, you may get the the line break between the soap body and the first element.

The problem should be easy to solve with a recursive method, but I was wondering, if there is a method for it? Like normalize etc.

Edit:

XML Response:

...
XMLSchema-instance"><soapenv:Body>
<wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/200/02/trust">...

JAVA CODE:

final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder db = factory.newDocumentBuilder();
Document result = db.newDocument();
//messResult is the response
result.appendChild(result.importNode(messResult.getSOAPBody().getFirstChild(),true));

Error Log:

HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml