ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to handle illegal characters in CData section

Post new topic  Reply to topic
 How to handle illegal characters in CData section « View previous topic :: View next topic » 
Author Message
shubham_057
PostPosted: Wed Apr 30, 2014 8:19 am    Post subject: How to handle illegal characters in CData section Reply with quote

Novice

Joined: 24 Mar 2014
Posts: 14

I am using WebSphere Message Broker which has a message flow that reads XML messages from a queue. If the messages is of NON STANDARD type (not as per XML standards) it is converted to BLOB object and audited to an Oracle database.

The problem is NON STANDARD messages instead of getting audited into d/b are falling into backout queue.

On investigating i came to know that the XML body contain a CData Section which had a special character (0x02) which is an illegal character for CData

I was wondering if it is possible to handle illegal characters without modifying the XML.

here is the code (in ESQL) where the NON STANDARD message is casted into BLOB type:

Code:

If FIELDNAME(InputBody.msg.header.application_name) IS NOT NULL Then
MOVE msgRef TO InputBody.msg;
      Set MSGBlob = BITSTREAM(msgRef);
      Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId);

      Set srcApp = msgRef.header.application_name;

      IF FIELDNAME(msgRef.header.msid) IS NOT NULL Then
         Set msid = msgRef.header.msid;
      ELSE
         Set msid = '9997';
      END IF;

      Set mType = 'Unset:ATLAS_MESSAGE';
      Set uuid = UUIDASCHAR;

      Insert Into Database.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY)
      Values (uuid,msid,mType,srcApp,'',MSGChar);

Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Apr 30, 2014 8:24 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Why not read the messages as a blob in the first place.
Then in a Compute Node (or any other valid node) PARSE the Message Data. If this fails, the flow can be designed to roll back to the Input Node.
In the Exeption Processing you will have the Original message as a BLOB. This can be written to the ORacle DB.

Just a thought...
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
shubham_057
PostPosted: Wed Apr 30, 2014 11:31 pm    Post subject: Reply with quote

Novice

Joined: 24 Mar 2014
Posts: 14

@smdavies : thanks for replying. As you said i have done something similar.
I have added one more node to insert exception into message and then pass it to a compute node 'WriteNonXMLToAudit'.

here is the code for it :

Code:


CREATE COMPUTE MODULE "WriteNonXMLToAudit_1_0_WriteNonXMLToAudit"
   CREATE FUNCTION main() RETURNS BOOLEAN BEGIN
      SET OutputRoot = InputRoot;
      DECLARE ver CHAR;
      DECLARE codeName CHAR;
      SET ver = '1_0_2';
      SET codeName = 'WriteNonXMLToAudit.' || 'Version:' || ver;
      DECLARE aonMSG REFERENCE To "OutputRoot"."BLOB";
      DECLARE appError REFERENCE To InputExceptionList;      
      DECLARE msid INTEGER;
      DECLARE messageType CHAR;      
      DECLARE sourceApplication CHAR;      
      DECLARE mqHdrBlob BLOB;
      DECLARE mqHdrChar CHAR;
      DECLARE msgBlob BLOB;
      DECLARE msgChar CHAR;
      DECLARE msgUUID CHAR;      
      SET OutputRoot.MQMD.Format = 'MQSTR   ';
      SET OutputRoot.MQMD.CodedCharSetId = 819;
      SET OutputRoot.MQMD.Encoding = 273;
      SET OutputRoot."MQRFH2" = NULL;
      MOVE aonMSG TO "OutputRoot"."BLOB";
      SET msgChar = aonMSG;
      SET messageType = 'NON_STANDARD_MESSAGE';
      SET msid = 9998;
      --SET msgUUID = CAST(OutputRoot.MQMD.MsgId As CHAR CCSID 819 ENCODING OutputRoot.MQMD.Encoding );
      SET msgUUID = UUIDASCHAR;
      SET sourceApplication = RTRIM(OutputRoot.MQMD.PutApplName);
      --SET msgChar = CAST(msgBlob As CHAR CCSID 819);
      SET msgChar = CAST(OutputRoot."BLOB"."BLOB" As CHAR CCSID 819 ENCODING OutputRoot.MQMD.Encoding );
 
      Insert Into Database.Message_Audit (UUID, MSID, Message_Type, Source_Application, Message_Body)
      Values ( SUBSTRING(msgUUID FROM 1 FOR 35),
      msid,
      SUBSTRING(messageType FROM 1 FOR 29),
      SUBSTRING(sourceApplication FROM (LENGTH(sourceApplication) - 9) FOR 10),
      msgChar);

      IF SQLCODE <> 0 THEN
         RETURN FALSE;
      END IF;

      RETURN TRUE;

   END;

END MODULE;



but still no luck.
I'm getting this in broker log:

Code:


WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2230E: Error detected whilst processing a message in node 'ACIF_AUDIT_1_5.Insert audit record'

WebSphere Broker v7005[15201]: (UKS06.ACIF_001)[35]BIP2488E:  (.ACIF_AUDIT_1_5_Insert audit record.main, 16.1) Error detected whilst executing the SQL statement 'DECLARE refAONDataRoot REFERENCE TO InputBody.MSG;'.

(UKS06.ACIF_001)[35]BIP2498E: (.ACIF_AUDIT_1_5_Insert audit record.main, 16.39) : An error occurred when navigating to path element '2' of the field reference at the given location.

(UKS06.ACIF_001)[35]BIP5009E: XML Parsing Errors have occurred.

(UKS06.ACIF_001)[35]BIP5004E: An XML parsing error 'Invalid character (Unicode: 0x2) ' occurred on line 1 column 441 when parsing element 'app_data'.  Internal error codes are '196' and ''.

(UKS06.ACIF_001)[35]BIP2628E: Exception condition detected on input node 'ACIF_AUDIT_1_5.ACIF_AUDIT_01'.

(UKS06.ACIF_001)[35]BIP2230E: Error detected whilst processing a message in node 'ACIF_AUDIT_1_5.ACIF_ERROR_01'.

(UKS06.ACIF_001)[35]BIP5010E: XML Writing Errors have occurred.

(UKS06.ACIF_001)[35]BIP5005E: There are 2 top level elements 'msg,MSG' in the document.


here is the message flow :

[img]https://drive.google.com/file/d/0B2Sd1Ur3yjLsbXIwN2Z5cDlpSXM/edit?usp=sharing[/img]

Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Apr 30, 2014 11:46 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Quote:

(UKS06.ACIF_001)[35]BIP2498E: (.ACIF_AUDIT_1_5_Insert audit record.main, 16.39) : An error occurred when navigating to path element '2' of the field reference at the given location


Run the test again but use USERTRACE (not forgetting to disable and debug points)
The trace output will show you where this happened.

however, if you were smart, you would have copied the original BLOB input ro the Environment Before parsing the message. Then if there is an error, you could jest get the saved BLOB from the environment and use that in your error handler.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
shubham_057
PostPosted: Thu May 01, 2014 12:50 am    Post subject: Reply with quote

Novice

Joined: 24 Mar 2014
Posts: 14

Code:

(UKS06.ACIF_001)[35]BIP2498E: (.ACIF_AUDIT_1_5_Insert audit record.main, 16.39) : An error occurred when navigating to path element '2' of the field reference at the given location


Above error is because the reference to first element of the message received is set as:

Code:
Declare refAONDataRoot REFERENCE To InputBody.MSG;


while the message's first element is <msg> ... </msg>.

Anyway the above error can be neglected as there is a part of code (which is in ACIF_AUDIT_1.5 see the msg flow image for reference) that handles messages with <msg> tag which is as follows :
Code:

ElseIf FIELDNAME(InputBody.msg.header.application_name) IS NOT NULL Then
      
      MOVE msgRef TO InputBody.msg;
      Set MSGBlob = BITSTREAM(msgRef);
      Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId);

      Set srcApp = msgRef.header.application_name;

      IF FIELDNAME(msgRef.header.msid) IS NOT NULL Then
         Set msid = msgRef.header.msid;
      ELSE
         Set msid = '9997';
      END IF;

      Set mType = 'Unset:ATLAS_MESSAGE';
      Set uuid = UUIDASCHAR;

      Insert Into Database.MESSAGE_AUDIT (UUID,MSID,MESSAGE_TYPE,SOURCE_APPLICATION,MQ_HEADER,MESSAGE_BODY)
      Values (uuid,msid,mType,srcApp,'',MSGChar);
      
      Else
      
      RETURN TRUE;
   End If;


hope now it makes some sense.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu May 01, 2014 6:23 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Code:

ElseIf FIELDNAME(InputBody.msg.header.application_name) IS NOT NULL Then
       
      MOVE msgRef TO InputBody.msg;
      Set MSGBlob = BITSTREAM(msgRef);
      Set MSGChar = CAST(MSGBlob As CHAR CCSID InputRoot.MQMD.CodedCharSetId);

This will not do what you think.
At this point your message has already been parsed and found wanting.
If not then the BITSTREAM (please use ASBITSTREAM) would force the parse with the original parser and the exception, hence should you ever get to MSGChar it would be null.

What you need to do on this error handling path, is, right after the input node, set a content redescriptor node that sets the domain to BLOB. you can then save the full message payload (BLOB) to your audit DB.

Have fun.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to handle illegal characters in CData section
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.