Attachments¶
Inline Base64 attachments¶
soap-cli can help you inline attachments into the SOAP body by replacing cid:CID placeholders with the Base64 contents of files when you provide one or more --attachment arguments.
--attachment <CID>=<path>– read the file at<path>, encode it as Base64, and replace exact occurrences ofcid:<CID>in the SOAP XML with that Base64 string.- The option can be repeated multiple times with different CIDs.
- Matching is exact:
cid:testdoes not matchcid:test02.
Example:
java -jar SoapCLI.jar \
--endpoint https://example.com/service \
--request-file request.xml \
--attachment message=/tmp/file.bin
In your SOAP XML you might have:
After processing, soap-cli will inline the Base64 content of /tmp/file.bin in place of cid:message and send a single application/soap+xml request (no multipart/related).
If no --attachment is provided, the request body is sent as-is.
Attachments with MTOM/XOP¶
When you want to send attachments using MTOM (as SoapUI does against the Domibus wsplugin), you can combine --attachment with --mtom:
--mtom– send the SOAP request asmultipart/relatedwith anapplication/xop+xmlroot part.--attachment <CID>=<path>– adds a binary part withContent-ID: <CID>and replacescid:<CID>in the SOAP body with anxop:Includereference.
Important CID rule¶
For MTOM/XOP to work correctly with typical servers (including Domibus):
- Anywhere you reference the attachment in the SOAP XML, you use
cid:<CID>, e.g.payloadId="cid:message1"orhref="cid:message1". - The corresponding MIME part must have
Content-ID: <message1>(angle brackets are MIME syntax; the ID itself ismessage1).
In other words, the value after cid: in the SOAP envelope must match the value inside the Content-ID header of the attachment part.
Example (similar to a Domibus wsplugin call):
java -jar SoapCLI.jar \
--endpoint http://localhost:18080/domibus/services/wsplugin \
--request-file request.xml \
--attachment message1=/tmp/payload.xml \
--mtom
In your SOAP XML you might have:
<ns:PayloadInfo>
<ns:PartInfo href="cid:message1">
<ns:PartProperties>
<ns:Property name="MimeType">text/xml</ns:Property>
<ns:Property name="PayloadName">payload.xml</ns:Property>
</ns:PartProperties>
</ns:PartInfo>
<soap:Body>
<eu:submitRequest>
<payload payloadId="cid:message1" contentType="text/xml">
<value>cid:message1</value>
</payload>
</eu:submitRequest>
</soap:Body>
</ns:PayloadInfo>
With --mtom, soap-cli will:
- Build a
multipart/relatedmessage with: - Root part:
application/xop+xml; type="application/soap+xml"containing the SOAP Envelope. - Attachment part: binary body with
Content-ID: <message1>. - Transform the literal
cid:message1in element content into:
This mirrors the MTOM/XOP structure generated by SoapUI against the Domibus wsplugin.
If --mtom is not specified, soap-cli does not use MTOM and behaves as described in the inline Base64 section.