Network Deployment (Distributed operating systems), v8.0 > Reference > Developer best practices


Transcoding a byte array into a message payload

A mediation can transcode a byte array into a message payload without changing the meaning of the message.


Example

A mediation can reconstruct the message payload from a byte array, for example after logging a message.

To reconstruct the message, call the method createDataGraph provided by the SIDataGraphFactory API. This method requires a byte array and a format string and creates a new data graph by parsing the bytes according to the format passed to the method, as shown in the following example:

DataGraph newDataGraph = SIDataGraphFactory.getInstance().createDataGraph(byteArray, newFormat);


Example

The table below describes the rules for transcoding a byte array into an SIMessage data graph.

Rules for transcoding a byte array into an SIMessage data graph. The first column of the table contains the format arguments used for transcoding a byte array into an SIMessage data graph. The second column provides the preconditions if available for the format arguments. The third column provides the resultant SIMessage data graphs for the specified format arguments.

Format 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

Verify 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.


Related


Transcoding between message formats

+

Search Tips   |   Advanced Search