SOAP Attachments

Applies to ReadyAPI 3.52, last modified on April 18, 2024

ReadyAPI supports multiple ways to add attachments to your SOAP requests – from inlining the attachment file to using MTOM to make sure your attachments are sent in an efficient manner.

Attachments With Type Defined Automatically

ReadyAPI can analyze the schema and send the attachment with the appropriate type automatically. This way, you can attach your files both inline and by using MIME-like approaches such as SwaRef or MTOM.

When you attach a file, a unique ContentID will be assigned to it. You can then reference this ID from the node you plan to attach the file to and let ReadyAPI resolve the attachment automatically:

Attachment Type The Attachment Should Be in Assigned Type Example
Inline The base64Binary or hexBinary data element. Content <xsd:element name="binaryData" type="xsd:base64Binary">
<xsd:element name="binaryData" type="xsd:hexBinary">
MTOM A data element of some XMIME data type. XOP <xsd:element name="binaryData" type="xmime:base64Binary"

<xsd:element name="binaryData" type="xmime:hexBinary"
SwaRef The attachment is in the wsi:swaRef element. SWAREF <xsd:element name="binaryData" type="wsi:swaRef"

Attaching Files to Requests

To attach a file to a request by using its ContentID:

  1. Open the Attachments panel and click Add Attachment.

    Attachments in ReadyAPI: Adding SOAP attachments

    Click the image to enlarge it.

  2. Select the file you want to send. ReadyAPI will ask you whether you want to cache it in the request. Uncached attachments are read from the file directly each time the request is sent. Cached attachments are stored in the project and are not changed when you update the original file.

  3. Specify cid:<Sample.xml> in the element you plan to attach the file to.

    Attachments in ReadyAPI: Specifying attachment part

    Click the image to enlarge it.

Now, when you send a request, ReadyAPI will analyze the schema definition for the element you attached and send the attachment with the appropriate type.

Sample Requests

Here are some examples of files attached to requests in different ways.

<soapenv:Envelope xmlns:soapenv="">
<sample:Attachment_Add xmlns:sample="">

Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <[email protected]>

<soapenv:Envelope xmlns:soapenv="" xmlns:xm="">
<binaryData><inc:Include href="cid:sample.gif" xmlns:inc=""/></binaryData>
Content-Type: image/gif; name=sample.gif
Content-Transfer-Encoding: binary
Content-ID: <sample.gif>
Content-Disposition: attachment; name="sample.gif"; filename="sample.gif"

... binary image data ...

Content-Type: Multipart/Related; start-info="text/xml"; type="application/xop+xml";
Content-Length: 1193
SOAPAction: ""

Content-Type: application/xop+xml; type="text/xml"; charset=utf-8

<soapenv:Envelope xmlns:soapenv="">



Attachments Specified With File Path

If your request has base64Binary or hexBinary data elements, you can add the attachment to it by specifying the path to the file. To do this:

  1. Set the Enable Inline Files request property to true.

  2. Add the reference to the file in the element you need it in, for example:


When you run the request, ReadyAPI will get the specified file and send it to the server.

Attachments Added Directly to Request

Instead of attaching the file to the request and letting ReadyAPI Test handle the transformation, you can convert the file to the Base64 encoding and insert it manually to where you need it. To do this, right-click the place where you need the attachment to be and select Insert file as Base64. Then, select the file to be inserted to a request.


Attachments not Specified in Service Definition

If you need to send an attachment not specified in the service definition, add it to the Attachments panel and select <anonymous> in the Part column.

Related Materials

See Also

REST Attachments

Highlight search results