First we will look at different types of handling WebServices with Attachments and later, we will let you know to work with preferred way of handling them in IBM Integration Designer or WebSphere Integration Developer.
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.
- enabled through a configuration option in the import and export bindings as described in Enabling MTOM support in JAX-WS bindings
- should be used to encode attachments for new applications.
- MTOM optimization is only available for the xs:base64Binary data type.
Referenced attachments
- referenced from the SOAP body; i.e the attachment is defined in the WSDL portType schema for the input or output message for the operation,
- the reference appears in the SOAP body as an element that references the attachment using the attachment's content-Id.
- To support SOAP messages with referenced attachments for exports,
- the interface operations must use the document literal non-wrapped binding style or the RPC literal binding style
- the input or output in the operation containing the reference must be binary
swaRef attachments
- A SOAP with attachment (swaRef) type attachment uses the Web Services Interoperability Organization (WS-I) Attachments Profile.
- To pass an attachment as a swaRef type using the WS-I Attachments Profile, follow these steps:
- Add the WS-I attachment profile to your module. Open Dependencies in the Business Integration view and in the Predefined Resources section select WS-I attachment profile 1.0 swaRef schema file. Save your work.
- To add an attachment in a business object, create a business object and for the type select swaRef, which will be available since you added the schema previously.
- To add an attachment as a type for an input or output to an operation, create the operation in the interface.
- Add an input or output to the operation.
- If using the business object created previously then select the business object as the type to your input or output.
- If you are not using the business object created earlier, add another input or output and select swaRef as the type.
- Generate the binding, deploy the your application and run it.
Unreferenced attachments
- do not have a reference from the SOAP body to the attachment.
- not modeled in the WSDL portType of messages and do not appear in the business object representation.
- can only be accessed through the Service Message Object (SMO).
- each attachment appears as a separate element in the attachments list of the SMO
Bindings and protocols that can be used with attachments
Only the Java API for XML Web Services (JAX-WS) based binding supports attachments in WID version 6.2.0.1 or higher.
Only the SOAP 1.2/HTTP or SOAP1.1/HTTP transport protocols can be used with attachments.
Working with MTOM Attachments in Integration Designer
Of all different ways to handle the Web Services with Attachments, MTOM approach is preferred way. This mechanism improves the transmission efficiency of large binary attachments in SOAP messages.Enabling MTOM support in JAX-WS bindings:
- SOAP messages that use the MTOM specification can be sent and received by enabling support in IBM Integration Developer using JAX-WS import and export binding properties.
- On the Properties for the export or import, click the Binding tab and select the MTOM check box. This will enable the optimization of the transmission of binary data in the SOAP attachment
- Control the size of attachment to be sent using MTOM with Threshold field
- is optional, integer value
- indicates the minimum size of binary data to be sent using MTOM.
- attachment size >= threshold, will be sent using MTOM
- attachment size < threshold, will be inlined in XML document
- 0 indicates all docs will be sent using MTOM
MTOM will not work in following scenarios:
- when the business object parsing mode is set to eager parsing (support is limited to a JAX-WS web service using business object lazy parsing mode).
- when using a JAX-WS handler (support is limited to a JAX-WS web service which does not use any JAX-WS handlers). The JAX-WS handlers specified on the web service should be removed.
- when using a service gateway mediation module, the Data Handler primitive cannot be used with MTOM messages. If direct access to the MTOM attachment data is required within the module, then a non-service gateway module must be used.
- when MTOM is enabled on a JAX-WS export binding, all responses will be sent using MTOM. If some clients do not support MTOM, use two JAX-WS exports - one with MTOM enabled and one with it disabled and ensure client applications use the correct endpoint address.
- when using the JAX-RPC binding for SOAP/HTTP or SOAP/JMS.
No comments:
Post a Comment