Writing a mediation that maps between attachment encoding styles
Use this topic to create a mediation that maps from SOAP Messages with Attachments encoding style to WS-I Attachments Profile Version 1.0 encoding style.
For an introduction to using mediations with the service integration bus, see Learning about mediations. For details of how to install a mediation into WAS and associate it with a bus destination, see Work with mediations.
This topic assumes that we are familiar with using a Java EE session bean development environment such as the assembly tools or IBM Rational Application Developer.
The example mediation given in this topic is based upon the WSDL examples that are given in Supporting bound attachments: WSDL examples
Use a mediation to map from a SOAP Messages with Attachments encoding of a message to WS-I Attachments Profile Version 1.0 encoding. The WSDL definition is the same in both cases, so if we create a mediation that rewrites the Content ID values to match the Version 1.0 conventions then the message is encoded by service integration technologies according to Version 1.0 rules.
To create a mapping mediation, use a Java EE session bean development environment to complete the following steps:
Tasks
- Create an empty mediation handler project. This creates the project, and creates the handler class that implements the handler interface. For detailed instructions on how to do this, see Writing the mediation handler.
- Use the mediation pane on the EJB descriptor to define the handler class as a mediation handler.
When we do this, we specify a name by which the mediation handler list is known. Make a note of this name, for later reference when we create the mediation in the bus.
- Add the mapping function to the handler. Before you begin, review Add mediation function to handler code. Here is an example of mediation handler code that rewrites the Content ID values to match the Version 1.0 conventions:
int uuidBase = 0; DataObject root = SIMessage.getDataGraph().getRootObject(); List attachments = root.getList("info/attachments"); Iterator entries = attachments.iterator(); while(entries.hasNext()) { DataObject entry = (DataObject) entries.next(); if(entry.getType().equals("BoundMIMEAttachmentEntryType")) { String newContentId = entry.getString("messagePart") + "=" + Integer.toString(uuidBase++) + "@some.domain"; } }For messages that use a SOAP with attachments reference (swaref) or some other URI mechanism to refer to the attachments, the URI values might also have to be updated to match the new Content ID values. However such mechanisms are usually used to refer to unbound attachments. For more information about the service integration technologies classes, including the mediation handler classes, see the Generated API documentation - Application programming interfaces .
- Export the mapping mediation enterprise application.
What to do next
We are now ready to install your mediation into WAS and associate it with a bus destination, as described in Work with mediations.
Mapping of SDO data graphs for web services messages