MTOM/XOP and SOAP
When MTOM/XOP is used to optimize a SOAP message, it is serialized into a MIME Multipart/Related message using XOP processing. The base64Binary data is extracted from the SOAP message and packaged as separate binary attachments within the MIME message, in a similar manner to e-mail attachments.
The size of the base64Binary data is significantly reduced because
the attachments are encoded in binary format. The XML in the SOAP
message is then converted to XOP format by replacing the base64Binary
data with a special <xop:Include>
element that
references the relevant MIME attachment using a URI.
The modified SOAP message is called the XOP document, and forms the root document within the message. The XOP document and binary attachments together form the XOP package. When applied to the SOAP MTOM specification, the XOP package is a MIME message in MTOM format.
Content-Type: Multipart/Related; boundary=MIME_boundary;
type="application/soap+xml"; start="<claim@insurance.com>"
The start parameter
contains the Content-ID of the XOP document. If this parameter is
not included in the content-type header, the first part in the MIME
message is assumed to be the XOP document. The order of the attachments in the MIME message is unimportant. In some messages for example, the binary attachments could appear before the XOP document. An application that handles MIME messages must not rely on the attachments appearing in a specific order. For detailed information, read the MTOM/XOP specifications.
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xmime="http://www.w3.org/2003/12/xop/mime">
<soap:Body>
<submitClaim>
<accountNumber>5XJ45-3B2</accountNumber>
<eventType>accident</eventType>
<image xmime:contentType="image/jpeg" xsi:type="base64binary">4f3e..(encoded image)</image>
</submitClaim>
</soap:Body>
</soap:Envelope>
An MTOM/XOP version of this SOAP message
is as follows: MIME-Version: 1.0
Content-Type: Multipart/Related; boundary=MIME_boundary;
type="application/soap+xml"; start="<claim@insurance.com>" 1
--MIME_boundary
Content-Type: application/soap+xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <claim@insurance.com> 2
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xop='http://www.w3.org/2004/08/xop/include'
xmlns:xop-mime='http://www.w3.org/2005/05/xmlmime'>
<soap:Body>
<submitClaim>
<accountNumber>5XJ45-3B2</accountNumber>
<eventType>accident</eventType>
<image xop-mime:content-type='image/jpeg'><xop:Include href="cid:image@insurance.com"/></image> 3
</submitClaim>
</soap:Body>
</soap:Envelope>
--MIME_boundary
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-ID: <image@insurance.com> 4
...binary JPG image...
--MIME_boundary--
- The start parameter indicates which part of the MIME message is the root XOP document.
- The Content-ID value identifies a part of the MIME message. In this case it is the root XOP document.
- The
<xop:Include>
element references the JPEG binary attachment. - The Content-ID identifies the JPEG in the binary attachment.