public SOAPMessage setSOAPBody ( SOAPMessage msg , BaseMessage message ) { try { if ( msg == null ) msg = fac . createMessage ( ) ; // Message creation takes care of creating the SOAPPart - a // required part of the message as per the SOAP 1.1 // specification. SOAPPart soappart = msg . getSOAPPart ( ) ; // Retrieve the envelope from the soap part to start building // the soap message. SOAPEnvelope envelope = soappart . getEnvelope ( ) ; // Create a soap header from the envelope. //?SOAPHeader header = envelope.getHeader(); // Create a soap body from the envelope. SOAPBody body = envelope . getBody ( ) ; DOMResult result = new DOMResult ( body ) ; if ( ( ( BaseXmlTrxMessageOut ) message . getExternalMessage ( ) ) . copyMessageToResult ( result ) ) { // Success // Note: For Jabx, I would have to fix the namespace of the message (so don't use JAXB) msg . saveChanges ( ) ; return msg ; } } catch ( Throwable e ) { e . printStackTrace ( ) ; Utility . getLogger ( ) . warning ( "Error in constructing or sending message " + e . getMessage ( ) ) ; } return null ; }
This utility method sticks this message into this soap message s body .