org.ow2.petals.binding.soap.util
Class Marshaller

java.lang.Object
  extended by org.ow2.petals.binding.soap.util.Marshaller

public final class Marshaller
extends java.lang.Object

A marshaller to create JBI message from SOAP ones and vice versa.

Author:
Christophe HAMERLING (chamerling) - eBM WebSourcing

Method Summary
static void copyAttachments(org.apache.axiom.om.OMElement from, javax.jbi.messaging.NormalizedMessage to)
          Create the JBI message from the OMElement object.
static org.apache.axiom.soap.SOAPBody createSOAPBody(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.soap.SOAPEnvelope envelope, javax.xml.transform.Source source)
          Create a SOAPBody from a source
static org.apache.axiom.soap.SOAPBody createSOAPBodyWithFault(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.soap.SOAPEnvelope envelope, javax.xml.transform.Source source)
          Create a SOAPBody from a source with a fault
static org.apache.axiom.soap.SOAPEnvelope createSOAPEnvelope(org.apache.axiom.soap.SOAPFactory factory, javax.jbi.messaging.NormalizedMessage nm, boolean isJBIFault)
          Creates a SOAP response from a NormalizedMessage
static javax.xml.transform.Source createSourceContent(org.apache.axiom.soap.SOAPEnvelope soapEnvelope, boolean axis1Compatibility)
          Create a the JBI payload from the SOAP body.
static javax.xml.transform.Source createSourceContentAndAttachment(org.apache.axis2.context.MessageContext inContext)
          Create the JBI payload from the soap body.
static void fillSOAPBodyWithAttachments(javax.jbi.messaging.NormalizedMessage nm, org.apache.axiom.soap.SOAPFactory soapFactory, org.apache.axis2.context.MessageContext messageContext)
           Handles attachments.
static void setAttachments(org.apache.axiom.attachments.Attachments attachments, javax.jbi.messaging.NormalizedMessage to)
          Put the SOAP attachments in the normalized message
static void setProperties(org.apache.axis2.context.MessageContext from, javax.jbi.messaging.NormalizedMessage to)
          Copy properties from a SOAP message to the normalized message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyAttachments

public static void copyAttachments(org.apache.axiom.om.OMElement from,
                                   javax.jbi.messaging.NormalizedMessage to)
                            throws javax.jbi.messaging.MessagingException
Create the JBI message from the OMElement object.

Parameters:
from -
outBodyElement -
to -
Throws:
javax.jbi.messaging.MessagingException

createSOAPBody

public static org.apache.axiom.soap.SOAPBody createSOAPBody(org.apache.axiom.soap.SOAPFactory factory,
                                                            org.apache.axiom.soap.SOAPEnvelope envelope,
                                                            javax.xml.transform.Source source)
                                                     throws javax.jbi.messaging.MessagingException
Create a SOAPBody from a source

Parameters:
factory - a SOAP factory
envelope - a SOAP envelope
source - a source
Returns:
the SOAP body
Throws:
javax.jbi.messaging.MessagingException

createSOAPBodyWithFault

public static org.apache.axiom.soap.SOAPBody createSOAPBodyWithFault(org.apache.axiom.soap.SOAPFactory factory,
                                                                     org.apache.axiom.soap.SOAPEnvelope envelope,
                                                                     javax.xml.transform.Source source)
                                                              throws javax.jbi.messaging.MessagingException
Create a SOAPBody from a source with a fault

Parameters:
factory - a SOAP factory
envelope - a SOAP envelope
source - a source
Returns:
the SOAP body
Throws:
javax.jbi.messaging.MessagingException

createSOAPEnvelope

public static org.apache.axiom.soap.SOAPEnvelope createSOAPEnvelope(org.apache.axiom.soap.SOAPFactory factory,
                                                                    javax.jbi.messaging.NormalizedMessage nm,
                                                                    boolean isJBIFault)
                                                             throws javax.jbi.messaging.MessagingException
Creates a SOAP response from a NormalizedMessage

Parameters:
factory - soap factory
nm - NormalizedMessage containing the response
Returns:
a SOAPEnveloppe created from the nm NomalizedMessage content
Throws:
javax.jbi.messaging.MessagingException

createSourceContent

public static javax.xml.transform.Source createSourceContent(org.apache.axiom.soap.SOAPEnvelope soapEnvelope,
                                                             boolean axis1Compatibility)
                                                      throws javax.jbi.messaging.MessagingException
Create a the JBI payload from the SOAP body. The SOAP envelope is required to get namespaces.

Parameters:
envelope - the SOAP envelope
axis1Compatibility - a flag for Axis compatibility
Returns:
the source
Throws:
javax.jbi.messaging.MessagingException - if there is an error when creating the source content

createSourceContentAndAttachment

public static javax.xml.transform.Source createSourceContentAndAttachment(org.apache.axis2.context.MessageContext inContext)
                                                                   throws javax.jbi.messaging.MessagingException
Create the JBI payload from the soap body. The soap envelope is created from the inContext.getAttachmentMap().getSOAPPartInputStream() stream because it's dosen't contain the attachment as text element. That's avoid to put the attachment both in the JBI payload and in the JBI attachments.

Parameters:
inContext - the message context
Returns:
the source
Throws:
javax.jbi.messaging.MessagingException - if there is an error when creating the source content and attachements

fillSOAPBodyWithAttachments

public static final void fillSOAPBodyWithAttachments(javax.jbi.messaging.NormalizedMessage nm,
                                                     org.apache.axiom.soap.SOAPFactory soapFactory,
                                                     org.apache.axis2.context.MessageContext messageContext)
                                              throws org.apache.axis2.AxisFault

Handles attachments. Two cases can occurs:

In the first case, it is needed to replace the XML node that declares the attachment by the same using OMElement (it's needed by Axis API).

In the other case, each attachment is added, using MTOM/XOP, in the special node inside the SOAP Body: <soapbc:attachments xmlns:soapbc="http://petals.ow2.org/ns/soapbc">/<soapbc:attachment>

Parameters:
nm -
soapFactory -
messageContext -
Throws:
org.apache.axis2.AxisFault

setAttachments

public static void setAttachments(org.apache.axiom.attachments.Attachments attachments,
                                  javax.jbi.messaging.NormalizedMessage to)
Put the SOAP attachments in the normalized message

Parameters:
attachments -
to -

setProperties

public static void setProperties(org.apache.axis2.context.MessageContext from,
                                 javax.jbi.messaging.NormalizedMessage to)
                          throws javax.jbi.messaging.MessagingException
Copy properties from a SOAP message to the normalized message

Parameters:
from -
to - Normalized message
Throws:
javax.jbi.messaging.MessagingException


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.