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.
Before you begin
For an introduction to using mediations with the service integration
bus, see Learning about mediations.
For details of how to install a mediation into WebSphere Application Server
and associate it with a bus destination, see Working with mediations.
This
topic assumes that you are familiar with using a Java 2 platform, Enterprise
Edition (J2EE) session bean development environment such as the Application
Server Toolkit or 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
About this task
You can 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 you 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 2 platform, Enterprise
Edition (J2EE) session bean development environment to complete the following
steps:
Procedure
- 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.
Note: When you do this, you specify
a name by which the mediation handler list is known. Make a note of this name,
for later reference when you create the mediation in the bus.
- Add the mapping function to the handler. Before you
begin, review Adding 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”;
}
}
Note: 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 need to be updated to match the new Content ID values. However
such mechanisms are usually used to refer to unbound attachments.
For
more information on the service integration technologies classes, including
the mediation handler classes, see the generated API information.
- Export the mapping mediation enterprise application.
What to do next
You are now ready to install your mediation into WebSphere Application
Server and associate it with a bus destination, as described in
Working with mediations.