SOAP Message Transmission Optimization Mechanism (MTOM) is a standard that is developed by the World Wide Web Consortium (W3C). MTOM describes a mechanism for optimizing the transmission or wire format of a SOAP message by selectively re-encoding portions of the message while still presenting an XML Information Set (Infoset) to the SOAP application.
XOP defines a serialization mechanism for the XML Infoset with binary content that is not only applicable to SOAP and MIME packaging, but to any XML Infoset and any packaging mechanism. It is an alternate serialization of XML that just happens to look like a MIME multipart/related package, with an XML documents as the root part. That root part is very similar to the XML serialization of the document, except that base64-encoded data is replaced by a reference to one of the MIME parts, which is not base64 encoded. This reference allows you to avoid the bulk and overhead in processing that is associated with encoding. Encoding is the only way a binary data can fit directly into an XML world.
If MTOM mapping generation is disabled, then XOP is disabled. If XOP is disabled, the binary data are not sent by using MIME attachments. Instead, the binary data is base64 encoded as usual.
Implementing these abstract features requires concrete specification of two aspects: the optimized wire format and how the optimized wire format flows on a particular transport
The Java API for XML Web Services (JAX-WS) adds support for sending binary data attachments using MTOM. JAX-WS is the centerpiece of a newly re-architected API stack for Web service that includes JAX-WS 2.0, JAXB 2.0, and SAAJ 1.3. The API stack is sometimes referred to as the integrated stack. JAX-WS is designed to take the place of JAX-RPC in Web services and Web applications.
A different standard is defined by World Wide Web Consortium (W3C) and is called SOAP with Attachments (SwA). SwA was developed as a way to package SOAP messages with attachments. Because some vendors do not support SwA, SwA could be replaced by the more powerful MTOM and XOP mechanisms. SwA and MTOM are conceptually similar, and both encode binary data as a MIME attachment in a MIME document. Using MIME attachments improves the performance of large binary payloads transport.
SOAP 1.1 is based on the XML specification. Likely, the SOAP 1.1 implementation will continue to exist for a few years. For those who are still running SOAP 1.1, there is now an interoperable way to use MTOM for attachments support. SAP, Oracle, Microsoft, and IBM have submitted a SOAP 1.1 Binding for MTOM 1.0 specification to W3C, which defines how MTOM can be used with SOAP 1.1 payloads. The specification details the necessary modifications to the SOAP MTOM and XOP specifications that are necessary to successfully use these technologies with SOAP 1.1. See the information at this Web site:http://schemas.xmlsoap.org/soap/mtom/SOAP11MTOM10.pdf
MTOM is a SOAP Version 1.2 feature, which is based on the Infoset. For more information, see XML information set.
Without MTOM, the data is encoded in whatever format is described in the schema (base64 or hex) and then appears in the XML document. The following example shows a SOAP message with an <xsd:base64Binary> element:
... other transport headers ... Content-Type: text/xml; charset=UTF-8 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <sendImage xmlns="http://org/apache/axis2/jaxws/sample/mtom"> <input> <imageData>R0lGODl ... more base64 encoded data ... KTJk8giAAA7</imageData> </input> </sendImage> </soapenv:Body> </soapenv:Envelope>
When MTOM is enabled, the binary data that represents the attachment is included as a MIME attachment to the SOAP message. The following example shows an MTOM-enabled SOAP message with attachment data:
... other transport headers ... Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812; type="application/xop+xml"; start="<0.urn:uuid:0FE43E4D025F0BF3DC11582467646813@apache.org>"; start-info="text/xml"; charset=UTF-8 --MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812 content-type: application/xop+xml; charset=UTF-8; type="text/xml"; content-transfer-encoding: binary content-id: <0.urn:uuid:0FE43E4D025F0BF3DC11582467646813@apache.org> <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <sendImage xmlns="http://org/apache/axis2/jaxws/sample/mtom"> <input> <imageData> <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.urn:uuid:0FE43E4D025F0BF3DC11582467646811@apache.org"/> </imageData> </input> </sendImage> </soapenv:Body> </soapenv:Envelope> --MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812 content-type: text/plain content-transfer-encoding: binary content-id: <1.urn:uuid:0FE43E4D025F0BF3DC11582467646811@apache.org> ... binary data goes here ... --MIMEBoundaryurn_uuid_0FE43E4D025F0BF3DC11582467646812--