Is there a methode to linarize a Document?
- by M.R.
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.