Content-Type for SOAP with Attachments (MTOM)
Set the Content-Type header for SOAP MTOM (Message Transmission Optimization Mechanism) with multipart/related. Covers XOP and binary optimization.
XML/SOAP
Detailed Explanation
MTOM / multipart/related
MTOM (Message Transmission Optimization Mechanism) uses multipart/related to send SOAP messages with binary attachments efficiently, avoiding Base64 encoding overhead.
The Header Value
Content-Type: multipart/related; type="application/xop+xml"; start="<root.message@example.com>"; start-info="application/soap+xml"; boundary=MIME_boundary
Parameters Explained
| Parameter | Purpose |
|---|---|
type |
MIME type of the root part (application/xop+xml for MTOM) |
start |
Content-ID of the root part |
start-info |
Original Content-Type of the root (before XOP processing) |
boundary |
Boundary string separating parts |
Message Structure
--MIME_boundary
Content-Type: application/xop+xml; charset=utf-8; type="application/soap+xml"
Content-ID: <root.message@example.com>
Content-Transfer-Encoding: 8bit
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<UploadDocument>
<data>
<xop:Include href="cid:attachment1@example.com"
xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
</data>
</UploadDocument>
</soap:Body>
</soap:Envelope>
--MIME_boundary
Content-Type: application/pdf
Content-ID: <attachment1@example.com>
Content-Transfer-Encoding: binary
[Raw PDF binary data - NOT Base64 encoded]
--MIME_boundary--
Why MTOM?
Without MTOM, binary data in SOAP must be Base64-encoded, increasing size by ~33%. MTOM uses XOP (XML-binary Optimized Packaging) to reference binary parts directly, keeping binary data in its raw form.
When to Use
- Large file attachments in SOAP services
- High-performance enterprise integrations
- Medical imaging (DICOM over SOAP)
- Document management systems
Use Case
Use this when integrating with enterprise SOAP services that handle large binary attachments, such as medical imaging systems, document management platforms, or financial data exchange.