IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access web services using web service bindings

Work with attachments

Attachments provide a way to pass additional information in a message in an efficient manner by holding the attachment data separate from the message body.

For example, a SOAP message or email might contain a person's resume with an attachment that holds the person's photograph.

The following sections provide some conceptual information on attachments.


Bindings and protocols that can be used with attachments

Only the Java API for XML Web Services (JAX-WS) based binding supports attachments in version 6.2.0.1 or higher. Only the SOAP 1.2/HTTP or SOAP1.1/HTTP transport protocols can be used with attachments.


Types of attachments

There are four types of attachments: MTOM, referenced, swaRef type and unreferenced.

MTOM attachments use the SOAP Message Transmission Optimization Mechanism (MTOM) (http://www.w3.org/TR/soap12-mtom/) specified encoding. MTOM attachments are enabled through a configuration option in the import and export bindings as described in Enabling MTOM support in JAX-WS bindings and should be used to encode attachments for new applications. If that the MTOM optimization is only available for the xs:base64Binary data type.

Referenced attachments are referenced from the SOAP body; that is, the attachment is defined in the WSDL portType schema for the input or output message for the operation, and the reference appears in the SOAP body as an element that references the attachment using the attachment's content-Id. Referenced and swaRef-type attachments.shows you how to create a referenced attachment.

A SOAP with attachment (swaRef) type attachment uses the Web Services Interoperability Organization (WS-I) Attachments Profile. Referenced and swaRef-type attachments.shows you how to create a swaRef-type of attachment.

Unreferenced attachments do not have a reference from the SOAP body to the attachment. Unreferenced attachments are discussed in the next section.

In any of the types of attachments, the attachment data itself does not appear inline in the SOAP body XML.


Unreferenced attachments

Unreferenced attachments do not have a reference from the SOAP body to the attachment.

Unreferenced attachments are not modeled in the WSDL portType of messages and do not appear in the business object representation. They can only be accessed through the Service Message Object (SMO). Each attachment appears as a separate element in the attachments list of the SMO. See Service message objects.


Threshold attribute for MTOM

For MTOM enablement, the threshold attribute is used to determine if an attachment is needed for the binary data. If the binary data size is greater than or equal to the value of the threshold, an attachment is generated for that binary data. The exception to this behavior is if a pass-through scenario exists and in that case, the threshold value is ignored for the outgoing message. The pass-through scenario may be one of following situations:

  1. Export (MTOM in) -- connected directly --- Import (MTOM out)
  2. Export (MTOM in) -- MFC (do nothing or do not touch data in MFC ) --- Import (MTOM out)
In both situations, the incoming MTOM SOAP message will be XML semantically equal to the outgoing MTOM SOAP message.


Routing, storing and manipulating attachments

Using a mediation flow, you can route, store or manipulate an attachment passed in as a SMO attachment. You could route the attachment based on the type of attachment, or use a custom primitive to load or save attachment data. See Building mediation flows to see how to route, store and manipulate elements in messages with mediation flows.


Testing attachments

You can test applications that use attachments in the same way as other applications. The Integration Test Client can be used with little difference in how you use it to test an application using attachments. See Testing Web Service exports with SOAP messages. If that you must have enabled your server to work with attachments.


Security

A Web Services Security (WS-Security) policy set can be applied when using attachments, however, any privacy or integrity settings will not apply to the attachment data. In order to secure the entire message when using attachments, you should enable transport level security using HTTPS instead of HTTP, by attaching an appropriate policy set. This makes the entire HTTP message secure, including attachments


Limitations

Access web services using web service bindings