Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: MuleSoapHeadersHandler.java 10489 2008-01-23 17:53:38Z dfeist $
   * --------------------------------------------------------------------------------------
   * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
   *
   * The software in this package is published under the terms of the CPAL v1.0
   * license, a copy of which has been included with this distribution in the
   * LICENSE.txt file.
   */
 
 package org.mule.transport.soap.axis.extensions;
 
 
 
 import  org.apache.axis.AxisFault;
 import  org.apache.axis.MessageContext;
 import  org.apache.axis.handlers.BasicHandler;
MuleSoapHeadersHandler is an Axis handler that can read and write Mule header properties to a SOAP message.
 
 public class MuleSoapHeadersHandler extends BasicHandler
 {
    
Serial version
 
     private static final long serialVersionUID = 1813393257662701953L;

    
logger used by this class
 
     protected static final Log logger = LogFactory.getLog(MuleSoapHeadersHandler.class);
 
     public void invoke(MessageContext msgContextthrows AxisFault
     {
         boolean setMustUnderstand = msgContext.isPropertyTrue("MULE_HEADER_MUST_UNDERSTAND");
 
         try
         {
             if (msgContext.isClient())
             {
                 if (!msgContext.getPastPivot())
                 {
                     processClientRequest(msgContextsetMustUnderstand);
                     if (.isDebugEnabled())
                     {
                         .debug("After Client Request, Message is:\n"
                                         + msgContext.getRequestMessage().getSOAPPartAsString());
                     }
                 }
                 else
                 {
                     processClientResponse(msgContext);
                     if (.isDebugEnabled())
                     {
                         .debug("After Client Response, Message is:\n"
                                         + msgContext.getRequestMessage().getSOAPPartAsString());
                     }
                 }
             }
             else
             {
                 if (!msgContext.getPastPivot())
                 {
                     processServerRequest(msgContext);
                     if (.isDebugEnabled())
                     {
                         .debug("After Server Request, Message is:\n"
                                         + msgContext.getRequestMessage().getSOAPPartAsString());
                     }
                 }
                 else
                 {
                     processServerResponse(msgContextsetMustUnderstand);
                     if (.isDebugEnabled())
                     {
                         .debug("After Server Response, Message is:\n"
                                         + msgContext.getRequestMessage().getSOAPPartAsString());
                     }
                 }
             }
         }
         catch (Exception e)
         {
             throw AxisFault.makeFault(e);
         }
     }

    
Method processClientRequest

Parameters:
msgContext
    protected synchronized void processClientRequest(MessageContext msgContextboolean setMustUnderstand)
        throws Exception
    {
        SOAPMessage msg = msgContext.getMessage();
        if (msg == null)
        {
            return;
        }
        MuleEvent event = (MuleEvent)msgContext.getProperty(.);
        if (event == null)
        {
            return;
        }
        else
        {
            synchronized (msgContext)
            {
                MuleSoapHeaders headers = new MuleSoapHeaders(event);
                headers.addHeaders(msgContext.getMessage().getSOAPPart().getEnvelope());
            }
        }
    }

    
Method processClientResponse

Parameters:
msgContext
    protected void processClientResponse(MessageContext msgContextthrows Exception
    {
        SOAPMessage msg = msgContext.getMessage();
        if (msg == null)
        {
            return;
        }
        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
        MuleSoapHeaders headers = new MuleSoapHeaders(env.getHeader());
        if (headers.getCorrelationId() != null)
        {
            msgContext.setProperty(.headers.getCorrelationId());
        }
        if (headers.getCorrelationGroup() != null)
        {
            msgContext.setProperty(.headers
                .getCorrelationGroup());
        }
        if (headers.getCorrelationSequence() != null)
        {
            msgContext.setProperty(.headers
                .getCorrelationSequence());
        }
        if (headers.getReplyTo() != null)
        {
            msgContext.setProperty(.headers.getReplyTo());
        }
    }

    
Method processServerRequest

Parameters:
msgContext
Throws:
Exception
    protected void processServerRequest(MessageContext msgContextthrows Exception
    {
        SOAPMessage msg = msgContext.getMessage();
        if (msg == null)
        {
            return;
        }
        MuleSoapHeaders headers = new MuleSoapHeaders(msg.getSOAPPart().getEnvelope().getHeader());
        msgContext.setProperty(.headers);
    }

    
Method processServerResponse

Parameters:
msgContext
    protected void processServerResponse(MessageContext msgContextboolean setMustUnderstand)
        throws Exception
    {
        SOAPMessage msg = msgContext.getMessage();
        if (msg == null)
        {
            return;
        }
        MuleSoapHeaders headers = (MuleSoapHeaders)msgContext
            .getProperty(.);
        if (headers == null)
        {
            return;
        }
        else
        {
            headers.addHeaders(msgContext.getMessage().getSOAPPart().getEnvelope());
        }
    }
New to GrepCode? Check out our FAQ X