Message Transmission Optimization Mechanism (MTOM) provides a way to
send binary data to Web Services in standard SOAP messages. MTOM
leverages the include mechanism defined by XML Optimized Packaging (XOP)
whereby binary data can be sent as a MIME attachment (similar to SOAP
with Attachments) to a SOAP message. The binary data can then be referenced
in the SOAP message using the <xop:Include> element.
The following MTOM message contains a binary image encapsulated in
a MIME part. It is important to note that the MIME part that contains
the binary image is referenced in the SOAP request body using the
<xop:Include> element. The href
attribute of this element refers to the Content-ID HTTP header
of the MIME part.
| | |
|
POST /services/uploadImages HTTP/1.1
Host: SOAPbox
Content-Type: Multipart/Related;boundary=MIME_boundary;
type="application/xop+xml";
start="<mymessage.xml@example.org>";
start-info="text/xml"
--MIME_boundary
Content-Type: application/xop+xml;
charset=UTF-8;
type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <mymessage.xml@example.org>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<uploadGraphic xmlns="www.example.org">
<image>
<xop:Include xmlns:xop='http://www.w3.org/2004/08/xop/include'
href='cid:http://example.org/myimage.gif'/>
</image>
</uploadGraphic>
</soap:Body>
</soap:Envelope>
--MIME_boundary
Content-Type: image/gif
Content-Transfer-Encoding: binary
Content-ID: <http://example.org/myimage.gif>
// binary octets for image
--MIME_boundary
| |
| | |
|
When the Enterprise Gateway receives this request, the Insert MTOM Attachment
filter can be used to read the binary data in the MIME parts pointed to by the
<xop:Include> elements embedded in the SOAP request. The
binary data is then Base64-encoded and inserted into the message in place of the
<xop:Include> elements. The resulting message is as follows:
| | |
|
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<uploadGraphic xmlns="www.example.org">
<image>/aWKKapGGyQ=</image>
</uploadGraphic>
</soap:Body>
</soap:Envelope>
| |
| | |
|
|