You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by ge...@ws.apache.org on 2005/03/16 13:22:36 UTC

[Apache Web Services Wiki] New: Axis2/MTOM

   Date: 2005-03-16T04:22:36
   Editor: ThilinaGunarathne
   Wiki: Apache Web Services Wiki
   Page: Axis2/MTOM
   URL: http://wiki.apache.org/ws/Axis2/MTOM

   no comment

New Page:

##language:en
##language:en

Email: [thilina@opensource.lk]

= Implementation of MTOM for AXIOM =

== Architecture ==


'''MTOM''' ([http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/ SOAP Message Transmission Optimization Mechanism]) describes an abstract feature for optimizing the transmission and/or wire format of a SOAP message by selectively encoding portions of the message. 
This implementation focuses on implementing MTOM on top of AXIOM. 


=== De-Serializer ===

[http://www.cse.mrt.ac.lk/~gunarnkt/MTOM/img/mtom1.jpg http://www.cse.mrt.ac.lk/~gunarnkt/MTOM/img/mtom1.jpg]

'''T'''ransport module has given the responsibility of identifying MTOM messages and choosing between the right builder (MTOMStAXSOAPBuilder or StAXSOAPModelBuilder). Identifying MTOM messages can be done by looking at the “Content-Type” and “type” headers of the message.

     || Content-Type: Multipart/Related;boundary=MIME_boundary; ||
     || type="application/xop+xml"; ||

'''M'''TOMStAXSOAPBuilder assumes that the Input Stream provided to it contains an MTOM encoded MIME message. It passes that Input stream to MTOMBuilder. MTOMbuilder extracts the root mime part which contains the XOP soap message and returns a XMLStreamReader(parser) built using that Soap message to the MTOMStAXSOAPModelBuilder. This builder deferred builds the AXIOM using that parser.

'''W'''hen the builder comes across an xop:include element with the correct namespace, it creates an OMBlob node in the AXIOM. This OMBlob node keeps the “CID” value read from xop:include element and a reference to the MTOMbuilder in it.

     || <xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include' ||
     ||                          href='cid:http://example.org/me.png'/> ||
 
[http://www.cse.mrt.ac.lk/~gunarnkt/MTOM/img/mtom2.jpg http://www.cse.mrt.ac.lk/~gunarnkt/MTOM/img/mtom2.jpg]


'''O'''MBlob achieves deferred building by reading the MIME parts referenced by it only when a user requests the actual binary data value stored in it. When a request comes for the binary data, OMBlob use its MTOMBuilder reference and “CID” to obtain the correct Data Handler.


=== Serializer ===

'''M'''TOMXMLStreamReader has to be used when the message needs to be optimized using MTOM. This will ensure that OMBlobs in the AXIOM will be attached to the message by MTOM optimizing. This MTOMXMLStreamReader buffers the output stream taken from the internally initialized XMLStreamReader. When this serializes an OMBlob it generates an “CID” value and writes the <xop:include> element using it. At the same time it stores that “CID” & a reference to the OMBlob in a hash map. 

'''T'''he “complete()” method of the MTOMXMLStreamReader has to be called After serializing the whole document. At that point the MTOMXMLStreamReader generates the root mime part using the buffered outputStream data from the XMLStreamReader. Also it generates additional mime parts for all the OMBlob & CID pairs in the HashMap and creates a Mime message containing all. 

'''C'''ontent in the OMBlob will be serialized as base64encoded strings when plain XMLStreamReader is used to serialize an AXIOM containing OMBlobs. This can be used when it is decided not to use MTOM optimization. Other than that the binary attachments which are not qualified to be optimized will remain as base 64 strings in OMText nodes.


== References ==
    * [http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/ SOAP Message Transmission Optimization Mechanism]

    * [http://www.w3.org/TR/2005/REC-xop10-20050125/ XML-binary Optimized Packaging]

    * [http://www.java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/activation/ Java Activation Framework]

    * [http://java.sun.com/products/javamail/ Java Mail API]


-'''''Thilina Gunarathne'''''