Search code examples
ibm-integration-busextended-sql

Including the input message in the output message ESQL


Say I have an error handler subflow component in IIB that generates an error message, which is then output to a queue.

The error message is in a format similar to:

<ErrorMsg><Details>There was an error of some kind</Details><OriginalMsg></OriginalMsg></ErrorMsg>

The output from the MQInput Catch and Failure terminals points to the Input of the error handler. The message domain is set on the MQInput node for the main messageflow, and could be either XMLNSC or not specified.

Given this, if I wanted to include a copy of the original message in the error message, in the OriginalMsg tags (so it would need to be CData), how would I go about this?

I have tried something similar to the following (which a. requires XMLNSC anyway, and b. doesn't seem to work):

DECLARE InputMessageBlob BLOB ASBITSTREAM(inRef.XMLNSC, inRef.Properties.Encoding, inRef.Properties.CodedCharSetId);
DECLARE InputMessageChar CHAR CAST(InputMessageBlob AS CHAR CCSID 1208);
SET OutputRoot.XMLNSC.nm1:ErrorMsg.nm1:OriginalMsg.(XMLNSC.CDataField)nm1:Content = InputMessageChar;

The above allows me to deploy my bar files, but the output is just an empty tag.


Solution

  • The answer is to use InputBody:

    DECLARE InputMessageBlob BLOB ASBITSTREAM(InputBody);
    DECLARE InputMessageChar CHAR CAST(InputMessageBlob AS CHAR CCSID InputRoot.MQMD.CodedCharSetId);
    SET OutputRoot.XMLNSC.nm1:ErrorMsg.nm1:OriginalMsg.(XMLNSC.CDataField)nm1:Content = InputMessageChar;