Because Dispatch objects are low-level objects, they are not optimized for using the
same JAXB generated types as the higher level consumer APIs. Dispatch objects work with the
following types of objects:
A Dispatch object accepts and returns objects that are derived from the
javax.xml.transform.Source interface. Source objects are
supported by any binding, and in either message mode or payload mode.
Source objects are low level objects that hold XML documents. Each
Source implementation provides methods that access the stored XML documents and then
manipulate its contents. The following objects implement the Source interface:
DOMSourceHolds XML messages as a Document Object Model(DOM) tree. The XML message is stored as a set of
Node objects that are accessed using the getNode()
method. Nodes can be either updated or added to the DOM tree using the setNode()
method.
SAXSourceHolds XML messages as a Simple API for XML (SAX) object. SAX objects contain an
InputSource object that holds the raw data and an XMLReader
object that parses the raw data.
StreamSourceHolds XML messages as a data stream. The data stream can be manipulated the same as any other data stream.
Dispatch objects can use javax.xml.soap.SOAPMessage
objects when the following conditions are true:
The Dispatch object is using the SOAP binding
The Dispatch object is using message mode
A SOAPMessage object holds a SOAP message. They contain one
SOAPPart object and zero or more AttachmentPart objects. The
SOAPPart object contains the SOAP specific portions of the SOAP message including the SOAP
envelope, any SOAP headers, and the SOAP message body. The AttachmentPart objects contain
binary data that is passed as an attachment.
Dispatch objects can use objects that implement the
javax.activation.DataSource interface when the following conditions are true:
The Dispatch object is using the HTTP binding
The Dispatch object is using message mode
DataSource objects provide a mechanism for working with MIME typed data from a
variety of sources, including URLs, files, and byte arrays.
While Dispatch objects are intended to be low level APIs that allow you to work with
raw messages, they also allow you to work with JAXB objects. To work with JAXB objects a
Dispatch object must be passed a JAXBContext that can
marshal and unmarshal the JAXB objects in use. The JAXBContext is passed when the
Dispatch object is created.
You can pass any JAXB object understood by the JAXBContext object as the
parameter to the invoke() method. You can also cast the returned message
into any JAXB object understood by the JAXBContext object.
For information on creating a JAXBContext object see Using A JAXBContext Object.