MTOM – Message Transmission Optimization Mechanism

BusinessWorks supports SOAP Messages with attachment styles as SwA and MTOM (standards as per SOAP Specs). SwA stands for SOAP with Attachments and MTOM stands for Message Transmission Optimization Mechanism. MTOM is a method of efficiently sending binary data to and from Web Services. MTOM only optimizes element content that is in the representation of the xs:base64Binary data type

MTOM is basically a set of three features as listed below:

  1. Abstract SOAP Transmission Optimization Feature” for sending and receiving SOAP messages that contain binary data. The binary data is a part of the single XML Infoset model  – this is a feature wherein binary data is sent separately.
  2. Optimized MIME Multipart/Related Serialization of SOAP Messages” defines that the serialized XML infoset will include XOP (XML-binary Optimized Packaging) in place of the binary data, and the binary data will be represented together in a MIME container – it does not define the transport protocol over which that MIME and XOP SOAP message is sent.
  3. A “HTTP SOAP Transmission Optimization Feature” defines how the above MIME and XOP SOAP message is sent over HTTP.

 

Benefits of MTOM:

The efficiency claims of MTOM only refers to the size of the messages sent across the wire. Since SOAP is an XML representation, any binary data in the SOAP message will have to be encoded as text, done using Base64 encoding which increases the size of the binary data by 33%. MTOM provides a way to send the binary data in its original binary form, avoiding any increase in size due to encoding it in text.

 

XML Infoset prior to XOP Processing:

<soap:Envelope
    xmlns:soap='http://www.w3.org/2003/05/soap-envelope' 
    xmlns:xmlmime='http://www.w3.org/2004/11/xmlmime'>
  <soap:Body>
    <m:record xmlns:m='http://www.tibcobw.com/record'>
      <m:employeeImage 
  xmlmime:contentType='image/png'>/dGHKcrGHyW=</m:employeeImage>
      <m:sig 
  xmlmime:contentType='application/pkcs12-signature'>Gcd7rViWS=</m:sig>
    </m:record>
  </soap:Body>
</soap:Envelope>

 

XML Infoset serialized as a XOP package:

MIME-Version: 1.0
Content-Type: Multipart/Related;boundary=TIBCOBW_Example;
    type="application/xop+xml";
    start="<test.xml@tibcobw.com>";
    startinfo="application/soap+xml; action=\"ProcessEmployee\""
Content-Description: A SOAP message with employee image and signature used in it

--TIBCOBW_Example
Content-Type: application/xop+xml; 
    charset=UTF-8; 
    type="application/soap+xml; action=\"ProcessEmployee\""
Content-Transfer-Encoding: 8bit
Content-ID: <text.xml@tibcobw.com>

<soap:Envelope
    xmlns:soap='http://www.w3.org/2003/05/soap-envelope'
    xmlns:xmlmime='http://www.w3.org/2004/11/xmlmime'>
  <soap:Body>
    <m:record xmlns:m='http://www.tibcobw.com/record'>
      <m:employeeImage 
  xmlmime:contentType='image/png'><xop:Include 
    xmlns:xop='http://www.w3.org/2004/08/xop/include' 
    href='cid:http://www.tibcobw.com/employee13066.png'/></m:employeeImage>
      <m:sig 
  xmlmime:contentType='application/pkcs12-signature'><xop:Include 
    xmlns:xop='http://www.w3.org/2004/08/xop/include' 
    href='cid:http://www.tibcobw.com/employee13066.hsh'/></m:sig>
    </m:record>
  </soap:Body>
</soap:Envelope>

--TIBCOBW_Example
Content-Type: image/png
Content-Transfer-Encoding: binary
Content-ID: <http://www.tibcobw.com/employee13066.png>

// binary image data

--TIBCOBW_Example
Content-Type: application/pkcs12-signature
Content-Transfer-Encoding: binary
Content-ID: <http://www.tibcobw.com/employee13066.hsh>

// binary signature data

--TIBCOBW_Example--