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 » CDATA to MQ

Post new topic  Reply to topic Goto page 1, 2  Next
 CDATA to MQ « View previous topic :: View next topic » 
Author Message
anurag.munjal
PostPosted: Wed Sep 26, 2012 11:04 am    Post subject: CDATA to MQ Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Hi MB Champs!

I have a XML request message as below:
<body>
<payload>
<![CDATA[TheBodyOfCdataWhichIsToBePutOnTheQueue]]>
</payload>
</body>

I want to put the content of the CDATA i.e. 'TheBodyOfCdataWhichIsToBePutOnTheQueue' as it is without any transformation onto a MQ.

I have tried a lot of approaches but am missing the point!
Any suggestion?

Anurag Munjal
New delhi
+91 - 9990602099
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Sep 26, 2012 11:14 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Use ESQL or Java Compute node to form the output message in accordance with the information found in the InfoCentre.

http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp

You might read the value of the CDATA tag as a BLOB and assign the result to the MQ message payload.

What version of WMB are you using? Do you have a coach or mentor on your site? Have you attended the WMB training?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Wed Sep 26, 2012 12:25 pm    Post subject: Re: CDATA to MQ Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

anurag.munjal wrote:
I have tried a lot of approaches but am missing the point!


Such as? There's no point us suggesting something which has already proved to be ineffective for you.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
NealM
PostPosted: Wed Sep 26, 2012 1:59 pm    Post subject: Reply with quote

Master

Joined: 22 Feb 2011
Posts: 230
Location: NC or Utah (depends)

It can be hard for a newbie to understand that there is no "text" or "string" parser in the Broker. Any incoming/outgoing message of that type (that doesn't have a message set defined for it) needs to be treated as a BLOB. I suggest you spend a few minutes in the InfoCenter (see lancelot's link) reading up on BLOB. Especially note the examples in "Manipulating messages in the BLOB domain".
Regarding retrieving data from your XML, you don't need to worry about the CDATA tag, the Broker handles that. You just want to grab the contents of Root.XMLNS.Body.Payload in your ESQL's SET =.
If on the other hand you wanted to create an XML CDATA section, you then would need to read up on how to specify for your particular parser, XML/XMLNS/XMLNSC.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Sep 26, 2012 2:22 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

That's good advice from NealM.

Quote:
If on the other hand you wanted to create an XML CDATA section, you then would need to read up on how to specify for your particular parser, XML/XMLNS/XMLNSC.
That makes it sound as if there are three equally good options. In fact, XMLNSC is the best choice for a new message flow unless there are good reasons why not *and* you can articulate exactly what those reasons are. I think NealM was allowing for the possibility that you are working on a set of old flows that all use XMLNS.

Anyway, to avoid confusion, the ESQL that the OP needs is
Code:
DECLARE myCDATA CHARACTER;
SET myCData = InputRoot.XMLNSC.body.payload;
SET OutputRoot.BLOB.BLOB = CAST myCData as CHARACTER ENCODING <insert the required CCSID here>;
If you want to, you can collapse that into one line once you understand what's going on.
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Wed Sep 26, 2012 8:43 pm    Post subject: Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Hi lancelotlinc,
So true! am a newbie... plus my mentor is to busy to help me out! but yes, i will go through the link to gain better grip on the topic! Thanks

Hi Vitor,
The approaches i tried are not to point am sure. still ill tell u
1. i tried to put the cdata section content onto a tag in xml. i could do that all without any aprsing, but i was getting the '<![CDATA[' also. plus my requiremnt is to put the contents of the Cdata onto the queue. no tags are to be there.
2. i tried casting the cdata into blob, but i just came to know that broker treats it as blob only.
3. i tried using ASBITSTREAM but it didnt go that smooth!
4. and a few other hit and trials, am still learning!
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Wed Sep 26, 2012 8:57 pm    Post subject: Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Hi NealM,
So when u say that grab the contents of Root.XMLNS.Body.Payload in your ESQL's SET =, what shall i set it into? a character type variable? will this variable be able to store CDATA content?? what convertion do i need to do?? cast as character?

the data in the CDATA section is BLOB, right?
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Wed Sep 26, 2012 9:09 pm    Post subject: Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Hi Jedi Knight,
Thanks for the code snippet.
DECLARE myCDATA CHARACTER;
SET myCData = InputRoot.XMLNSC.body.payload;
SET OutputRoot.BLOB.BLOB = CAST myCData as CHARACTER ENCODING <insert the required CCSID here>;

My doubts are:
1. when u say, SET myCData = InputRoot.XMLNSC.body.payload; will the contents of cdata section flow into charecter type variable as it is? without the
'<![CDATA['?
2. when u say, SET OutputRoot.BLOB.BLOB = CAST myCData as CHARACTER ENCODING <insert the required CCSID here>, will the output queue get the contents of cdata?
am gona try this POC today!

Thanks a lot
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Wed Sep 26, 2012 9:11 pm    Post subject: Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Guys, i read it somewhere....
"extract the CData section as a BLOB". [/code]
Back to top
View user's profile Send private message
vikas.bhu
PostPosted: Wed Sep 26, 2012 9:14 pm    Post subject: Reply with quote

Disciple

Joined: 17 May 2009
Posts: 159

Cast the message in character..find the start position and end position of the message you want to put forward. and finally use substring function.
Hope it helps
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Wed Sep 26, 2012 11:18 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

kimbert wrote:
Anyway, to avoid confusion, the ESQL that the OP needs is
Code:
DECLARE myCDATA CHARACTER;
SET myCData = InputRoot.XMLNSC.body.payload;
SET OutputRoot.BLOB.BLOB = CAST myCData as CHARACTER ENCODING <insert the required CCSID here>;

The last line needs a few minor adjustments:

Code:
DECLARE myCDATA CHARACTER;
SET myCData = InputRoot.XMLNSC.body.payload;
SET OutputRoot.BLOB.BLOB = CAST(myCData as BLOB CCSID <insert the required CCSID here>);

This converts the CData contents from CHARACTER to BLOB using the given ccsid, and writes the resulting BLOB to the output message.
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Thu Sep 27, 2012 1:02 am    Post subject: rekarm01 - THANKSSSSSSSSS Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Hi rekarm01,
Ur suggestion is on target!

ITS WORKING!

I am so happy to be a part of this awsome community!! Thanks a lot guys!!

Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Sep 27, 2012 3:00 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Thanks rekarm01. Accurate as usual!

@vikas.bhu: Please don't offer bad advice on this forum.
Back to top
View user's profile Send private message
NealM
PostPosted: Thu Sep 27, 2012 4:54 am    Post subject: Reply with quote

Master

Joined: 22 Feb 2011
Posts: 230
Location: NC or Utah (depends)

One other thing, Anurag:
All data in an XML doc is always text, all elements/attributes, all the time. Valid characters for the codepage that is specified for the XML document. The data in a CDATA section is no exception. All it does is preserve whitespace (multiple/leading/trailing blanks, etc) in the data, whereas normal XML processing may remove some or all of them. So one uses CDATA to preserve a string exactly. If one wanted to send a BLOB as an element in an XML doc, what one does is send a pseudo-hex representation of a BLOB. Still character data. So a two byte piece of data would be sent as a 4 byte pseudo-hex (whether or not to include the "X'..'" surrounding the pseudo-hex is users choice). That requires a little more work in correctly CASTing at both ends. One would do that if you were trying to include non-text data in the XML, such as say packed decimal data, or data from a different CCSID, which would otherwise blow up in an XML processor/parser. That is not your case.
Back to top
View user's profile Send private message
anurag.munjal
PostPosted: Wed Oct 03, 2012 5:57 am    Post subject: Reply with quote

Voyager

Joined: 08 Apr 2012
Posts: 97

Thanks Neal!
one quick query:
Can you help me differentiate between these three statements?



SET OutputRoot.XMLNSC.Envelope.Body.(XMLNSC.CDataField)payload = some_msg;

SET OutputRoot.XML.Envelope.Body.(XML.CDataSection)payload = some_msg;

SET OutputRoot.XMLNSC.Envelope.Body.(XML.CDataSection)payload = some_msg;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CDATA to MQ
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.