You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by thilina Gunarathne <cs...@gmail.com> on 2005/03/09 15:49:08 UTC

[AXIS2] MTOM implementation design details

Hi all,

I'm writing this to give an introduction to the MTOM implementation
for AXIOM which is there at this instance. This is an evolving
implementation. So there will be  changes in next few days. I assume u
all r familiar with axis 2 & MTOM. Please feel free to make any
comments.

De-serialization
I altered and use the StAXOM Builder in the de-serialization part. 
This Builder is directly attached to the MTOMBuilder which handles the
mime message. StAXOMBuilder pass the InputStream which it gets & which
contains an MTOMized mime message to the MTOMBuilder. MTOMBuilder then
extracts SOAP Message in the root mime part. MTOM Builder instantiate
a StAXXMLReader from that mime part & passes it to the StAXOMBuilder
to be used. With that StAXOMBuilder works normally as earlier till it
finds an <XOP:include> element.

When it finds an <XOP:include>  element rather than  creating an
OMElement, it creates an OMBlob.  The value in href attribute ("CID")
and a reference to the MTOMBuilder is used to instantiate this OMBlob.
It won't need reading the MIME message parts to instantiate it.

Mime parts are read only when somebody accesses the actual data in the
OMBlob. At this point OMBlob requests the DataHandler appropriate (to
the previously assigned 'CID" value taken from <xop:include>),  from
the MTOMBuilder. Then only the OMBlob will receive its corresponding
binary attachment. This model achieves the differed parsing of Mime
Message.

In the "serializer" the user (Axis Engine…) has to select whether the
message is going to be optimized by MTOM or not. This can be selected
by choosing between the XMLStreamWriter classes he is going to use for
serialising.  MTOMXMLStreamWriter will optimize the message by MTOM
while the plain XMLStreamWriter will write the binary parts as base 64
encoded strings.
The MTOMXMLStreamWriter will instantiate an XMLStreamWriter inside it
and will  buffer XMLStreamWriter's OutputStream. MTOMXMLStreamWriter
will perform normally for all elements other than for OMBlobs. When it
gets a OMBlob to be serialized it'll generate a "cid" (Random) and
will serialize an <xop:include> element with the  "href - cid" as an
attribute using the XMLStreamWriter  instance & it'll also be written
in to the same Soap Message(OutputStream). At the same time
MTOMXMLStreamWriter stores that "cid" value and OMBlob reference in a
HashMap.

After finishing the passing of the whole message, the user has to
explicitly call the "complete()" method of the MTOMXMLStreamWriter. At
this point the MTOMXMLStreamWriter will use the buffered output from
XMLStreamWriter (the soap message) and creates the MIME root part
cotaining the soap message. Then it'll go through all the parts in the
HashMap (which contains "CID" & OMBlob references) to create Mime
parts with the Binary data contained in OMBlob as the content and the
"CID" value as the "Content-ID:" header value. This trick will achieve
deferred building of the message without double buffering attachment
data in the memory.

Further changes decided and that are on the development process of
applying to this implementation,
•	Above model was created with the thought of that the MTOMBuilder has
to Identify whether the incoming message is a MTOM message or a normal
soap message. Later it was found that the "transport" can distinguish
between above two message types by looking at the binding. Because of
that it is being decided to create MTOMXMLStreamReader class which
will handle MTOM Messages. Above reader could be used to de-serialze
the MTOM message when transport identifies that the incoming message
is a MTOM optimized message.

•	Binary data that are not to be optimized should be stored in an
OMText element. Then the Infoset preserving at two ends of the message
(client & server or intermediary….) could be achieved. OMText will be
modified to accommodate this.

Source can be found at svn. With one JUnit test case.

U can get this with diagrams @
http://www.cse.mrt.ac.lk/~gunarnkt/MTOM/mtomforaxis2.htm

kind regards

Thilina Gunarathne