@Override
  public boolean handleMessage(SOAPMessageContext context) {
    if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
      // Outbound message (request), so reset the last request and response builders.
      lastRequestInfo = new RequestInfo.Builder();
      lastResponseInfo = new ResponseInfo.Builder();      
      SOAPMessage soapMessage = context.getMessage();
      try {
        SOAPHeader soapHeader = soapMessage.getSOAPHeader();
        if (soapHeader == null) {
          soapHeader = soapMessage.getSOAPPart().getEnvelope().addHeader();
        }

        for (SOAPElement header : soapHeaders) {
          soapHeader.addChildElement(header);
        }
      } catch (SOAPException e) {
        throw new ServiceException("Error setting SOAP headers on outbound message.", e);
      }
      captureServiceAndOperationNames(context);
    }
    captureSoapXml(context);
    return true;
  }
@ Override public boolean handleMessage ( SOAPMessageContext context ) { if ( ( Boolean ) context . get ( MessageContext . MESSAGE_OUTBOUND_PROPERTY ) ) { lastRequestInfo = new RequestInfo . Builder ( ) ; lastResponseInfo = new ResponseInfo . Builder ( ) ; SOAPMessage soapMessage = context . getMessage ( ) ; try { SOAPHeader soapHeader = soapMessage . getSOAPHeader ( ) ; if ( soapHeader == null ) { soapHeader = soapMessage . getSOAPPart ( ) . getEnvelope ( ) . addHeader ( ) ; } for ( SOAPElement header : soapHeaders ) { soapHeader . addChildElement ( header ) ; } } catch ( SOAPException e ) { throw new ServiceException ( "Error setting SOAP headers on outbound message." , e ) ; } captureServiceAndOperationNames ( context ) ; } captureSoapXml ( context ) ; return true ; }
Captures pertinent information from SOAP messages exchanged by the SOAP
service this handler is attached to. Also responsible for placing custom
(implicit) SOAP headers on outgoing messages.

@see SOAPHandler#handleMessage(MessageContext)
@param context the context of the SOAP message passing through this handler
@return whether this SOAP interaction should continue