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); } }
protected void writeBodyFailure( Document d, Element bodyElement, ActionResponseMessage message, ActionInvocation actionInvocation) throws Exception { writeFaultElement(d, bodyElement, actionInvocation); message.setBody(toString(d)); }
protected void writeBodyResponse( Document d, Element bodyElement, ActionResponseMessage message, ActionInvocation actionInvocation) throws Exception { Element actionResponseElement = writeActionResponseElement(d, bodyElement, message, actionInvocation); writeActionOutputArguments(d, actionResponseElement, actionInvocation); message.setBody(toString(d)); }
protected Element writeActionResponseElement( Document d, Element bodyElement, ActionResponseMessage message, ActionInvocation actionInvocation) { log.fine("Writing action response element: " + actionInvocation.getAction().getName()); Element actionResponseElement = d.createElementNS( message.getActionNamespace(), "u:" + actionInvocation.getAction().getName() + "Response"); bodyElement.appendChild(actionResponseElement); return actionResponseElement; }
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); } }