The service message object (SMO) contains an attachments element
for each attachment associated with a SOAP message.
Introduction
The SMO attachments elements
let you send and receive SOAP messages that have attachments of various
types.
You might want to send SOAP messages with attachments
and let the attachments pass through the mediation flow unchanged,
or you might want to create new attachments, perhaps from information
in the message or from an external source.
Details
The SOAP attachments support relates
to unreferenced attachments, which are MIME parts included in a SOAP/HTTP
message and are not defined in the WSDL portType. The SOAP/HTTP message
consists of a MIME multipart message in which the SOAP body is the
first part and the attachments are subsequent parts (as defined in
the SOAP Messages with Attachments specification).
Each
attachment in the SOAP message is placed in an attachments element
in the SMO. The SMO has one attachments element for
each of the attachments in the SOAP message.
Each SMO
attachments element
contains the following information:
- A contentID element
- A contentType element
- A data element
The
contentID element contains the value of
the Content-ID header of the MIME part, and uniquely identifies the
attachment in the message. The
contentType element
contains the value of the Content-Type header of the MIME part, and
defines the type of data held by the attachment, for example
text/xml or
image/gif.
The
data element contains the attachment data.
You
can propagate SOAP attachments into and out of your module if it uses
any of the following bindings:
- Web service binding: SOAP 1.1/HTTP using JAX-WS
- Web service binding: SOAP 1.2/HTTP using JAX-WS
- SCA binding
You cannot propagate SOAP attachments if you use Web service
bindings that are based on JAX-RPC. In addition, you cannot propagate
SOAP attachments across any component types other than the mediation
flow component. Therefore, if you have a module that contains other
types of components, you must store the attachment somewhere and retrieve
it later. For example, you could use a Message Element Setter mediation
primitive to copy an attachment from the SOAP
attachments element
to the
userContext object.
An attachment cannot
exist without a message body.
Important: As
described in
"XML representation of SMO," the XSL Transformation
mediation primitive transforms messages using an XSLT 1.0 transformation.
The transformation operates on an XML serialization of the SMO. The
XSL Transformation mediation primitive allows the root of the serialization
to be specified, and the root element of the XML document reflects
this root.
When you are sending SOAP messages with attachments,
the root element you choose determines how attachments are propagated.
- If you use "/body" as the root of the XML map, all attachments
are propagated across the map by default.
- If you use "/" as the root of the map, you can
control the propagation of attachments.