Author |
Message
|
sumit |
Posted: Wed Oct 03, 2012 6:05 am Post subject: Remove CData and utilise complete XML |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
Hi All,
I am receiving a SOAP response message having strcuture-
Quote: |
<env>
- <body>
- <![CDATA[<?xml version="1.0" encoding="UTF-8"?>
- <A>
- ]]>
- </body>
</env> |
I need to remove the CData and send the message as (so that the final application can use it) -
Quote: |
<env>
- <body>
- <A>
- </body>
</env> |
For this, I am using ASBITSTREAM and CREATE-
Quote: |
DECLARE creationPtr REFERENCE TO OutputRoot.XMLNSC.env.body.DataContent;
declare encode INT InputProperties.Encoding;
DECLARE ccsid INT InputProperties.CodedCharSetId;
DECLARE inputmsg BLOB ASBITSTREAM(InputRoot.XMLNSC.env.body.(XMLNSC.CDataField), encode, ccsid);
CREATE LASTCHILD OF creationPtr DOMAIN('XMLNSC') PARSE(inputmsg, encode, ccsid, '','','',RootBitStream);
|
But I am getting BIP 2906 error. I also tried to use CREATE as
Quote: |
CREATE LASTCHILD OF creationPtr DOMAIN('XMLNSC') PARSE(inputmsg, encode, ccsid); |
I searched the forum and the infocenter when I faced the errors but looks like I am still missing something.
OS- Win XP
MB- 7.0.0.1 ( I know I can upgrade, but this doesn't look like cause of the problem) _________________ Regards
Sumit |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 03, 2012 6:10 am Post subject: Re: Remove CData and utilise complete XML |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
sumit wrote: |
MB- 7.0.0.1 ( I know I can upgrade, but this doesn't look like cause of the problem) |
There are more than 500 bug fixes between 7.0.0.1 and 7.0.0.5. How do you know one of these bug fixes might not affect your outcome? _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
sumit |
Posted: Wed Oct 03, 2012 6:29 am Post subject: |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Oct 03, 2012 6:35 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
sumit |
Posted: Wed Oct 03, 2012 7:23 am Post subject: |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
lancelotlinc wrote: |
Google is a wonderful tool. |
This time, 'direct' credit doesn't go to google; repeated search on mqseries.net gave me the appropriate result.
To point out, below command from the link worked for me.
Quote: |
SET Environment.variable.data = OutputRoot.XMLNSC.GetFormResponse.GetFormResult;
CREATE LASTCHILD OF Environment.Variable.XMLMessage DOMAIN ('XMLNSC') PARSE (Environment.variable.data CCSID 1200);
|
(I changed the CCSID to 437)
Have to read more about ASBITSTREAM.
While looking for the correct procedure, I referred this http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fac67175_.htm and the statement
Quote: |
The ASBITSTREAM function
If you code the ASBITSTREAM function with the parser mode option set to RootBitStream to parse a message tree to a bit stream, the result is an XML document that is built from the children of the target element in the normal way. |
made me feel that I need to use ASBITSTREAM.  _________________ Regards
Sumit |
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 03, 2012 7:49 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
It's actually even easier than that. I think some explanation of what is going on would help ( and see comment below about user trace ).
- The XMLNSC parser has parsed your input document.
- The content of the CData section is now represented as a CHARACTER field in the message tree. Note that the CData tags have been removed.
- You now want to parse the XML string that is held in the CHARACTER field 'myRef '.
Here's the long way to do it:
Code: |
DECLARE xmlAsBLOB CAST myRef AS BLOB CCSID 1208;
CREATE LASTCHILD OF myRef PARSE xmlAsBLOB DOMAIN 'XMLNSC' CCSID 1208;
|
This is encoding the character data in the message tree as a BLOB using UTF-8, and then asking the parser to parse the BLOB using UTF-8.
But message broker knows that a CHARACTER field needs to be converted to BLOB if you are giving to a parser. So it does that step for you. So this will also work:
Code: |
CREATE LASTCHILD OF creationPtr PARSE myRef DOMAIN 'XMLNSC'; |
[edited to swap the refs, as in the OP's example]
Final comment : user trace is a really good diagnostic tool. It is also a very useful educational tool, because it shows you some of what is happening 'under the hood'.
Last edited by kimbert on Wed Oct 03, 2012 7:58 am; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Oct 03, 2012 7:53 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The thing to remember about ASBITSTREAM is that it's the opposite of CREATE FIELD.. PARSE.
ASBITSTREAM takes a tree and turns it into a blob (... tree AS BITSTREAM... )
Create field takes a bitstream and turns it into a tree. |
|
Back to top |
|
 |
sumit |
Posted: Wed Oct 03, 2012 8:20 am Post subject: |
|
|
Partisan
Joined: 19 Jan 2006 Posts: 398
|
Thanks kimbert and mqjeff, it is much clear to me now. As suggested, will use trace node to witness the wonders  _________________ Regards
Sumit |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Oct 03, 2012 8:26 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
the suggestion was to use "user trace" which is not "trace node".
User trace is a way of seeing the execution of your flow, including the evaluation of each part of each ESQl statement.
A trace node shows you the value of any part of the logical message tree at a specific point in time. |
|
Back to top |
|
 |
|