|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Error in converting from MRM To XML |
« View previous topic :: View next topic » |
Author |
Message
|
jayeshn |
Posted: Wed Jun 29, 2005 5:17 am Post subject: Error in converting from MRM To XML |
|
|
 Newbie
Joined: 14 Jun 2005 Posts: 7 Location: India
|
Hi,
I am facing a problem in converting an MRM message into XML. Sorry for the long post but thought it would be better if I provide all the details. The details of my configuration are as follows -
My Message flow in MQSI is simple and consists of an MQInput node (MRMInput), Compute Node(MRM2XML), MQ Output nodes (XMLOutput) and (MRMFail) nodes.
I have created a message set 'CustomerMsgSet' and have added a CWF Format to it. I have imported a COBOL Copy book into the Message Set. it is as follows -
01 OUTPUT-DETAILS-MSG.
03 CUST.
05 CUSTNM PIC X(15).
05 CUSTID PIC 9(8).
I have created a message 'CustomerMsg' under CustomerMsgSet and the identifier for this msg is also 'CustomerMsg', Message Type for this message is CUST_TYPE.
The configuration of my MQInput node is as follows -
Message Domain:MRM
Message Set:CustomerMsgSet, 1(E5DT567G001)
Message Type:CustomerMsg
Message Format: CWF
Following is the code in my compute node -
Code: |
DECLARE C INTEGER;
SET C = CARDINALITY(InputRoot.*[]);
DECLARE I INTEGER;
SET I = 1;
WHILE I < C DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
SET OutputRoot.Properties.MessageDomain = 'XML';
SET OutputRoot.Properties.MessageFormat = 'XML';
SET OutputRoot.MQMD.CodedCharSetId = 819;
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.Format = MQFMT_STRING;
SET OutputRoot.XML.( "XML"."XmlDecl" ).( "XML"."Version" ) = '1.0';
SET OutputRoot.XML.( "XML"."XmlDecl" ).( "XML"."Encoding" ) = 'UTF-8';
SET OutputRoot.XML.CustomerMsg.CustomerName = "InputBody"."CUSTNM";
SET OutputRoot.XML.CustomerId = "InputBody"."CUSTID";
|
I have added the Message Set to the input side of the compute node.
After all this when I put an MRM String <Name 15 characters><id8digits> I get an error saying - ParserException BIP5005E: No valid body of the document could be found. There should be one, and only one, top level element of type Element or EmptyElement and this is not the case for the current message.
If I try to copy the entire message and comment my own code, it generates a proper XML with tag names same as those in the copy book i.e <CUST><CUSTNM> etc.
Am I navigating the MRM message incorrectly? If I try to navigate it using InputRoot.MRM.CUST.CUSTNM and InputRoot.MRM.CUST.CUSTID I get a blank XML since it fails to navigate to the MRM elements.
Some pointers on the above would be really helpful. _________________ Thanks,
Jayesh |
|
Back to top |
|
 |
recallsunny |
Posted: Wed Jun 29, 2005 5:52 am Post subject: MRM to XML |
|
|
 Disciple
Joined: 15 Jun 2005 Posts: 163 Location: Massachusetts
|
First things first! What is the root for your XML output? Because according to your ESQL code you are trying to create 2 root tags for your XML.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<CustomerMsg>
<CustomerName>ABC</CustomerName>
</CustomerMsg>
<CustomerId>123</CustomerId> |
This doesn't look like a well formed XML to my newbie eyes....hence you see the message.
"There should be one, and only one, top level element of type Element or EmptyElement and this is not the case for the current message"
Check your XML structure ! |
|
Back to top |
|
 |
javaforvivek |
Posted: Wed Jun 29, 2005 10:14 pm Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
Quote: |
SET OutputRoot.XML.CustomerMsg.CustomerName = "InputBody"."CUSTNM";
SET OutputRoot.XML.CustomerMsg.CustomerId = "InputBody"."CUSTID"; |
will generate something like this:
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<CustomerMsg>
<CustomerName>ABC</CustomerName>
<CustomerId>123</CustomerId>
</CustomerMsg>
|
_________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
JustFriend |
Posted: Mon Jul 04, 2005 9:22 am Post subject: |
|
|
Novice
Joined: 30 May 2005 Posts: 22
|
Hope the below would be useful. Your comments on this is appreciated.
Regards,
MOHD IQHBAL.
------------------------------------------------------------------
Cobol Copy:
01 OUTPUT-DETAILS-MSG.
03 CUST.
05 CUSTNM PIC X(15).
05 CUSTID PIC 9(8).
------------------------------------------------------------------
Let us assume that your input message looks like this:
CHAR-LENGTH: 1234567890123456789012345678901234567890
THE Message: Customer Name 00000012
------------------------------------------------------------------
Use the following in your compute node:
NOTE: XML is self-defining message, hence not essential that you need to have a Message-Set for generating XML message.
CALL CopyMessageHeaders();
SET OutputRoot.Properties.MessageDomain = 'XML';
SET OutputRoot.Properties.MessageFormat = 'XML';
-- Set Msg Properties
SET OutputRoot.Properties.MessageSet = '';
SET OutputRoot.Properties.MessageType = '';
SET OutputRoot.Properties.MessageFormat = 'MQSTR';
SET OutputRoot.Properties.Encoding = 546;
SET OutputRoot.Properties.CodedCharSetId = 437;
-- Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl) = '';
-- Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version) = '1.0';
-- Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding") = 'UTF-8';
-- Set Standalone within the XML Declaration
-- SET OutputRoot.XML.(XML.XmlDecl).(XML.Standalone) = 'no';
-- Use the below two if required
SET OutputRoot.XML.(XML.DocTypeDecl)MyDocType = '';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.SystemId) = './xyz.DTD';
-- Here I am using MRM.CUST.CUSTNM assuming that MRM is the root.
-- You can check this thru debugging and modify accordingly
SET OutputRoot.XML.(XML.Element)OUTPUT-DETAILS-MSG.CUST.CUSTNM
= CAST(InputRoot.MRM.CUST.CUSTNM AS CHAR);
SET OutputRoot.XML.(XML.Element)OUTPUT-DETAILS-MSG.CUST.CUSTID
= CAST(InputRoot.MRM.CUST.CUSTID AS CHAR);
RETURN TRUE;
------------------------------------------------------------------
The approx. output of this would be like this one:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MyDocType SYSTEM ./xyz.DTD">
<OUTPUT-DETAILS-MSG>
<CUST>
<CUSTNM>Customer Name</CUSTNM>
<CUSTID>12</CUSTID>
</CUST>
</OUTPUT-DETAILS-MSG>
------------------------------------------------------------------
NOTE: Here you are supplying Cust-ID as 00000012 but in the xml if you need with zeroes on the left use the below code:
DECLARE TmpID '00000000';
SET TmpID = OVERLAY(CAST(InputRoot.MRM.CUST.CUSTID AS CHAR) PLACING CAST(InputRoot.MRM.CUST.CUSTID AS CHAR) FROM (8 - LENGTH(CAST(InputRoot.MRM.CUST.CUSTID AS CHAR) + 1) FOR LENGTH(CAST(InputRoot.MRM.CUST.CUSTID AS CHAR)));
This would give you like '00000012'
------------------------------------------------------------------ |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|