Skip to content

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 of cid:<CID> in the SOAP XML with that Base64 string.
  • The option can be repeated multiple times with different CIDs.
  • Matching is exact: cid:test does not match cid: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:

<payload payloadId="cid:message" contentType="text/plain">
  <value>cid:message</value>
</payload>

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 as multipart/related with an application/xop+xml root part.
  • --attachment <CID>=<path> – adds a binary part with Content-ID: <CID> and replaces cid:<CID> in the SOAP body with an xop:Include reference.

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" or href="cid:message1".
  • The corresponding MIME part must have Content-ID: <message1> (angle brackets are MIME syntax; the ID itself is message1).

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/related message 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:message1 in element content into:
<inc:Include href="cid:message1" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>

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.