Transcoding between message formats

A mediation can convert a message from one format to another without changing the semantic meaning of the message. This operation is referred to as transcoding a message.

Example

The following code is an example mediation handler that transcodes a message into a new message format, providing that the message can be transcoded:
private static final String NEW_FORMAT = "JMS:text";

public boolean(MessageContext context) throws MessageContextException
{
  try
  {
    SIMessageContext msgCtx  = (SIMessageContext)context;
    SIMessage        msg     = msgCtx.getMessage();
    DataGraph        newDg   = msg.getNewDataGraph(NEW_FORMAT);

    msg.setDataGraph(newDg,NEW_FORMAT);
    return true;
  }
  catch(Exception e)
  {
    // Reroute the original message to the exception destination
    MessageContextException mce = new MessageContextException("Unable to transcode to "+NEW_FORMAT",e);
    throw mce;
  }
}

Example

The table below describes which messages can be transcoded, and gives the outcome for each format pairing. Note that the abbreviation DG represents "data graph". The numbers within brackets in the table are explained as follows:
Table 1. Transcoding messages
  To JMS: To JMS:text To JMS:bytes To JMS:stream To JMS:object To SOAP: To Bean:
From JMS: DG=null (1) DG=null (1) DG=null (1) DG=null (1) DG=null (1) DG=null (1) DG=null (1)
From JMS:text DG=null (2) Yes (3) Yes, bytes contain UTF-8 Yes, if text contains XML that conforms to the correct schema. No Yes, if message content is valid SOAP. Yes, if message content is valid SOAP.
From JMS:bytes DG=null (2) Yes, but only when the bytes can correctly be interpreted as a UTF-8 string. Yes (3) Yes, if bytes contain XML that conforms to the correct schema. Yes, assume that bytes are a serialized object. Yes, if message content is valid SOAP. Yes, if message content is valid SOAP.
From JMS:stream DG=null (2) Yes, text is XML transcoding. Yes, bytes contain XML transcoding. Yes (3) No No No
From JMS:object DG=null (2) No Yes, bytes contain the object serialization. No Yes (3) No No
From SOAP: DG=null (2) Yes Yes No No Yes (3) - if message content matches the new WSDL. Yes
From Bean: DG=null (2) Yes Yes No No Yes Yes (3) - if message content matches the new WSDL.

Example




Subtopics
XML schema definition for JMS stream messages
Transcoding a message payload into a byte array
Transcoding a byte array into a message payload
Web services messages overview
JMS formats
Related tasks
Working with the message payload
Related reference
XML schema definition for JMS stream messages
Transcoding a byte array into a message payload
Transcoding a message payload into a byte array
Reference topic Reference topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 4:28:44 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-mp&topic=transcode_msg_formats
File name: transcode_msg_formats.html