This topic describes the information for converting or transcribing
messages.
You can convert a message payload into a byte array,
for example for the purpose of logging a message, and you can reconstruct
the message from the byte array. Additionally, you can re-express the message
payload in a different format using the transcoding operation. For more information,
refer to the following topics:
Note that JMS:map is not supported.
XML Schema definition for stream messages
The
conversions defined in the following two tables use an XML Schema definition
with target namespace http://www.ibm.com/xmlns/prod/websphere/messaging/jms/
for expressing JMS stream messages in XML.
<xsd:schema elementFormDefault="qualified" xml:lang="EN"
targetNamespace="http://www.ibm.com/xmlns/prod/websphere/messaging/jms"
xmlns="http://www.ibm.com/xmlns/prod/websphere/messaging/jms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="data" type="StreamBody"/>
<xsd:complexType name="StreamBody">
<xsd:sequence>
<xsd:element name="value"
type="streamTypes"
minOccurs="0"
maxOccurs="unbounded"
nillable="true"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="character">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="streamTypes">
<xsd:union memberTypes="xsd:long xsd:int xsd:short xsd:byte xsd:boolean xsd:float xsd:double xsd:string xsd:hexBinary character"/>
</xsd:simpleType>
</xsd:schema>
Data graph to bytes conversion
You can convert
a message payload into a byte array, for example for the purpose of logging
a message. The following table summarizes the rules associated with each message
format when converting a message payload into a byte array:
Table 1. Conversion
of SIMessage datagraph to bytes.Datagraph format |
Pre-conditions |
Outcome |
Character set encoding |
JMS: |
None |
Returns null. |
Not applicable. |
JMS:text |
None |
Returns the result of java.lang.String:getBytes(String
charSetName) when applied to the data/value element
of the graph, where charSetName = “UTF-8" |
UTF-8 |
JMS:bytes |
None |
Returns a copy of the value of the data/value element
of the data graph for the message. |
Not applicable. |
JMS:stream |
None |
Returns a byte buffer containing an XML serialization
of the stream message according to the XML schema for stream messages. |
UTF-8 |
JMS:object |
None |
Returns a copy of the value of the data/value element
of the data graph for the message. |
Not applicable. |
SOAP: |
If the byte array must be generated by this operation
(instead of using an existing byte array available through lazy parsing)
then the data graph must be valid with respect to the WSDL model. |
Returns a byte buffer containing a SOAP serialization
of the data graph. If the SOAP message contains an attachment, the buffer
has the multipart MIME format. |
Either UTF-8, or that of the source message for the
graph, where logically equivalent to the graph state. |
Bean: |
The DataGraph must be valid with respect to the WSDL
model. In the absence of a SOAP binding the serialization will be performed
using RPC/literal encoding. |
Returns a byte buffer containing a SOAP serialization
of the data graph. If the Bean contains attachments then the buffer will be
in multipart MIME format. |
UTF-8 |
Bytes to data graph conversion
You can reconstruct
the message payload from a byte array, for example after a mediation has logged
a message. The following table summarizes the rules associated with converting
the byte array into the message payload:
Table 2. Conversion of bytes
to SIMessage data graphFormat argument |
Pre-conditions |
Outcome |
JMS: |
None |
Returns null |
JMS:text |
java.lang.String(inputBytes, ”UTF-8”) does
not result in an exception. |
Returns new data graph instance of format JMS:text.
Value of graph at path data/value has value
equal to java.lang.String(inputBytes, ”UTF-8”). |
JMS:bytes |
inputBytes is not null. |
Returns new data graph instance of format JMS:bytes.
Value of graph at path data/value is a copy
of the inputBytes byte array. |
JMS:stream |
Byte array is XML, and is valid with respect to the JmsStreamBody type
of the XML schema definition. |
Returns new data graph instance of format JMS:stream.
Value of graph at path data/value has type List,
containing a sequence of simple typed values according to the types and values
of each of the elements in the XML document. |
JMS:object |
Not null Note: You must ensure that the byte array is
a valid serialized object.
|
Returns new data graph instance of format JMS:object.
Value of graph at path data/value is a copy
of the inputBytes byte array. |
SOAP: |
The byte buffer contains valid SOAP with respect to
the associated WSDL model. |
Returns new data graph with type system defined by the
WSDL referenced by the byte buffer, and values of the graph defined by the
SOAP payload. |
Bean: |
The byte buffer contains valid Bean with respect to
the associated WSDL model. |
Returns new data graph with type system defined by the
WSDL referenced by the byte buffer, and values of the graph defined by the
Bean payload. |
Transcoding between different message formats
You
can re-express the message payload in a different format using the transcoding
operation. The following table summarizes the message formats that you can
transcode, and the rules associated with each format pairing. Each cell in
the table shows the result of attempting to transcode
from the format
given in the row title
to the format given by the column title.
Note: The
abbreviation DG is used for data graph.
Table 3. Allowed and disallowed
transcodings between message formats |
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. |
Notes:
- A message with format JMS: does not have a payload so the DataGraph returned
is always null. It is not valid to have a JMS:text DataGraph with the data
set to null. A mediation that has a JMS: message and requires a JMS:text DataGraph
should call createDataGraph() rather than attempt to turn a null value into
another value.
- Since a JMS: message does not have a payload, all operations which specify
a to format of JMS: will return a null value for the new DataGraph.
- You can call getNewDataGraph() with the same format as the original data
graph. It returns a copy of the data graph that you can edit, leaving the
original message unchanged. For SOAP and Beans, you can change the message
model by editing the format string to change the value that follows the “:”.