org.apache.camel.dataformat.soap
Class SoapJaxbDataFormat

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.converter.jaxb.JaxbDataFormat
          extended by org.apache.camel.dataformat.soap.SoapJaxbDataFormat
All Implemented Interfaces:
CamelContextAware, Service, ShutdownableService, DataFormat

public class SoapJaxbDataFormat
extends JaxbDataFormat

Marshaling from Objects to SOAP and back by using JAXB. The classes to be processed need to have JAXB annotations. For marshaling a ElementNameStrategy is used to determine how the top level elements in SOAP are named as this can not be extracted from JAXB.


Field Summary
protected  org.slf4j.Logger log
           
static String SOAP_UNMARSHALLED_HEADER_LIST
           
 
Constructor Summary
SoapJaxbDataFormat()
          Remember to set the context path when using this constructor
SoapJaxbDataFormat(String contextPath)
          Initialize with JAXB context path
SoapJaxbDataFormat(String contextPath, ElementNameStrategy elementNameStrategy)
          Initialize the data format.
SoapJaxbDataFormat(String contextPath, String elementNameStrategyRef)
          Initialize the data format.
 
Method Summary
protected  void checkElementNameStrategy(Exchange exchange)
           
protected  JAXBContext createContext()
          Added the generated SOAP package to the JAXB context so Soap datatypes are available
 void marshal(Exchange exchange, Object inputObject, OutputStream stream)
          Marshal inputObjects to SOAP xml.
 void setElementNameStrategy(ElementNameStrategy elementNameStrategy)
           
 void setElementNameStrategy(Object nameStrategy)
           
 void setElementNameStrategyRef(String nameStrategyRef)
           
 void setIgnoreUnmarshalledHeaders(boolean ignoreHeaders)
           
 Object unmarshal(Exchange exchange, InputStream stream)
          Unmarshal a given SOAP xml stream and return the content of the SOAP body
 
Methods inherited from class org.apache.camel.converter.jaxb.JaxbDataFormat
doStart, doStop, getCamelContext, getContext, getContextPath, getEncoding, getPartClass, getPartNamespace, isFilterNonXmlChars, isFragment, isIgnoreJAXBElement, isPrettyPrint, needFiltering, setCamelContext, setContext, setContextPath, setEncoding, setFilterNonXmlChars, setFragment, setIgnoreJAXBElement, setPartClass, setPartNamespace, setPrettyPrint
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOAP_UNMARSHALLED_HEADER_LIST

public static final String SOAP_UNMARSHALLED_HEADER_LIST
See Also:
Constant Field Values

log

protected final transient org.slf4j.Logger log
Constructor Detail

SoapJaxbDataFormat

public SoapJaxbDataFormat()
Remember to set the context path when using this constructor


SoapJaxbDataFormat

public SoapJaxbDataFormat(String contextPath)
Initialize with JAXB context path

Parameters:
contexPath -

SoapJaxbDataFormat

public SoapJaxbDataFormat(String contextPath,
                          ElementNameStrategy elementNameStrategy)
Initialize the data format. The serviceInterface is necessary to determine the element name and namespace of the element inside the soap body when marshalling

Parameters:
contextPath - package for JAXB context
serviceInterface - webservice interface

SoapJaxbDataFormat

public SoapJaxbDataFormat(String contextPath,
                          String elementNameStrategyRef)
Initialize the data format. The serviceInterface is necessary to determine the element name and namespace of the element inside the soap body when marshalling

Parameters:
contextPath - package for JAXB context
elementNameStrategyRef - webservice interface referenced bean name
Method Detail

setElementNameStrategy

public void setElementNameStrategy(Object nameStrategy)

setIgnoreUnmarshalledHeaders

public void setIgnoreUnmarshalledHeaders(boolean ignoreHeaders)

checkElementNameStrategy

protected void checkElementNameStrategy(Exchange exchange)

marshal

public void marshal(Exchange exchange,
                    Object inputObject,
                    OutputStream stream)
             throws IOException
Marshal inputObjects to SOAP xml. If the exchange or message has an EXCEPTION_CAUGTH property or header then instead of the object the exception is marshaled. To determine the name of the top level xml elements the elementNameStrategy is used.

Specified by:
marshal in interface DataFormat
Overrides:
marshal in class JaxbDataFormat
Parameters:
exchange - the current exchange
inputObject - the object to be marshalled
stream - the output stream to write the marshalled result to
Throws:
IOException

unmarshal

public Object unmarshal(Exchange exchange,
                        InputStream stream)
                 throws IOException
Unmarshal a given SOAP xml stream and return the content of the SOAP body

Specified by:
unmarshal in interface DataFormat
Overrides:
unmarshal in class JaxbDataFormat
Parameters:
exchange - the current exchange
stream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
IOException

createContext

protected JAXBContext createContext()
                             throws JAXBException
Added the generated SOAP package to the JAXB context so Soap datatypes are available

Overrides:
createContext in class JaxbDataFormat
Throws:
JAXBException

setElementNameStrategy

public void setElementNameStrategy(ElementNameStrategy elementNameStrategy)

setElementNameStrategyRef

public void setElementNameStrategyRef(String nameStrategyRef)


Apache CAMEL