The SOAP with Attachments Specification
The specification Soap Messages With Attachments defines a multipart message format called a SOAP message package. A SOAP message package is constructed according to the following rules:
*The SOAP header’s Content-Type element must be the multipart/related media type.
*The SOAP message itself is carried in the root body part of the multipart/related structure, so the type parameter of the multipart/related media header must be text/xml.
*MIME attachments are referenced inside the SOAP message body using SOAP references.
*Referenced MIME attachments must contain either a matching Content-ID header or a matching Content-Location header.
The specification also recommends that the root part contain a Content-ID header, and that the multipart/related media header contain a matching start parameter. This permits more robust error detection.
Figure 10 – SOAP Message with Attachments
The code below shows a SOAP 1.1 message package that contains a SOAP message in the root part that references an attached base64-encoded GIF image:
MIME-Version: 1.0
Content-Type: multipart/related; boundary="MIME_Boundary";
type=text/xml; start="<>"
Content-ID: <>
Content-Type: text/xml; charset=us-ascii
<SOAP-ENV:Envelope xmlns:SOAP-ENV=
<photo href=""/>
Content-ID: <>
Content-Type: image/gif
Content-Transfer-Encoding: base64
.... base64 encoded gif data
In this example, the element in the SOAP message
<photo href=""/>
references the attached image with the corresponding Content-ID header.
The sections that follow describe how to send and receive SOAP messages with MIME attachments over HTTP using HydraExpress. These sections assume you are familiar with the basic steps for using HydraExpress to generate code and develop Web services.