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.
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|
|MTOM||A data element of some
|SwaRef||The attachment is in the
To attach a file to a request by using its ContentID:
Open the Attachments panel and click Add Attachment.
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.
cid:<Sample.xml> in the element you plan to attach the file to.
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.
Here are some examples of files attached to requests in different ways.
Content-Type: text/xml; charset=UTF-8
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<binaryData><inc:Include href="cid:sample.gif" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></binaryData>
Content-Type: image/gif; name=sample.gif
Content-Disposition: attachment; name="sample.gif"; filename="sample.gif"
... binary image data ...
If your request has
hexBinary data elements, you can add the attachment to it by specifying the path to the file. To do this:
Set the Enable Inline Files request property to
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.
Instead of attaching the file to the request and letting SoapUI 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.
If you need to send an attachment not specified in the service definition, add it to the Attachments editor and select
<anonymous> in the Part column.