public void writeBody(ActionResponseMessage responseMessage, ActionInvocation actionInvocation) throws UnsupportedDataException { log.fine("Writing body of " + responseMessage + " for: " + actionInvocation); try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document d = factory.newDocumentBuilder().newDocument(); Element body = writeBodyElement(d); if (actionInvocation.getFailure() != null) { writeBodyFailure(d, body, responseMessage, actionInvocation); } else { writeBodyResponse(d, body, responseMessage, actionInvocation); } if (log.isLoggable(Level.FINER)) { log.finer( "===================================== SOAP BODY BEGIN ============================================"); log.finer(responseMessage.getBodyString()); log.finer( "-===================================== SOAP BODY END ============================================"); } } catch (Exception ex) { throw new UnsupportedDataException("Can't transform message payload: " + ex, ex); } }
public void readBody(ActionResponseMessage responseMsg, ActionInvocation actionInvocation) throws UnsupportedDataException { log.fine("Reading body of " + responseMsg + " for: " + actionInvocation); if (log.isLoggable(Level.FINER)) { log.finer( "===================================== SOAP BODY BEGIN ============================================"); log.finer(responseMsg.getBodyString()); log.finer( "-===================================== SOAP BODY END ============================================"); } String body = getMessageBody(responseMsg); try { DocumentBuilderFactory factory = createDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder documentBuilder = factory.newDocumentBuilder(); documentBuilder.setErrorHandler(this); Document d = documentBuilder.parse(new InputSource(new StringReader(body))); Element bodyElement = readBodyElement(d); ActionException failure = readBodyFailure(d, bodyElement); if (failure == null) { readBodyResponse(d, bodyElement, responseMsg, actionInvocation); } else { actionInvocation.setFailure(failure); } } catch (Exception ex) { throw new UnsupportedDataException("Can't transform message payload: " + ex, ex, body); } }