org.apache.camel.dataformat.soap
Class SoapJaxbDataFormat

java.lang.Object
  extended by org.apache.camel.converter.jaxb.JaxbDataFormat
      extended by org.apache.camel.dataformat.soap.SoapJaxbDataFormat
All Implemented Interfaces:
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.


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.
 
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 inputObject to SOAP xml.
 void setElementNameStrategy(ElementNameStrategy elementNameStrategy)
           
 void setElementNameStrategy(Object nameStrategy)
           
 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
getContext, getContextPath, getEncoding, getPartClass, getPartNamespace, isFilterNonXmlChars, isIgnoreJAXBElement, isPrettyPrint, needFiltering, setContext, setContextPath, setEncoding, setFilterNonXmlChars, setIgnoreJAXBElement, setPartClass, setPartNamespace, setPrettyPrint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 marshaling

Parameters:
jaxbPackage - package for JAXB context
serviceInterface - webservice interface
Method Detail

setElementNameStrategy

public void setElementNameStrategy(Object nameStrategy)

checkElementNameStrategy

protected void checkElementNameStrategy(Exchange exchange)

marshal

public void marshal(Exchange exchange,
                    Object inputObject,
                    OutputStream stream)
             throws IOException
Marshal inputObject 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 elment 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)


Apache CAMEL