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 » Convert an XML from the InputRoot, into a plain xml

Post new topic  Reply to topic
 Convert an XML from the InputRoot, into a plain xml « View previous topic :: View next topic » 
Author Message
broly
PostPosted: Thu Jan 31, 2013 9:44 am    Post subject: Convert an XML from the InputRoot, into a plain xml Reply with quote

Newbie

Joined: 02 Aug 2012
Posts: 6

Hi Folks.

I've spent like 3 days trying to solve this problem.
My requirement is as follows: From the InputRoot I receive an XML,
but inside the body of the SOAP message, there's a part of XML
I want to extract.
Once I've extracted the part of the XML,
I need to transform it into a String to store it in a
Character variable to manipulate it.

What I have until this moment is the new xml using the "ASBITREAM" function but the xml result has converted some Attributes into elements.
Do you have any ideas about this???

This is the code I have:

Code:

DECLARE contenidoXML CHARACTER '';
SET OutputRoot.XMLNSC.ws:getFileXMLResponse.cfd:Comprobante = Environment.getFileXMLResponse;
SET contenidoXML = CAST(ASBITSTREAM (OutputRoot.XMLNSC) AS CHARACTER CCSID 1208);
SET OutputRoot.XMLNSC = NULL;


Thanks[/code]
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Jan 31, 2013 9:50 am    Post subject: Re: Convert an XML from the InputRoot, into a plain xml Reply with quote

Grand High Poobah

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

broly wrote:
but inside the body of the SOAP message, there's a part of XML
I want to extract.


How is this stored? CData section? Or do you mean some subset of the SOAP message payload XML?

broly wrote:
Once I've extracted the part of the XML,
I need to transform it into a String to store it in a
Character variable to manipulate it.


Why? If it's XML, why do you want (or need) to manipulate it as a string?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Thu Jan 31, 2013 10:11 am    Post subject: Reply with quote

Jedi Knight

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

I think you are missing the RootBitStream parameter which is discussed extensively in the training class.
_________________
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
broly
PostPosted: Thu Jan 31, 2013 10:15 am    Post subject: Re: Convert an XML from the InputRoot, into a plain xml Reply with quote

Newbie

Joined: 02 Aug 2012
Posts: 6

Vitor wrote:

How is this stored? CData section? Or do you mean some subset of the SOAP message payload XML?


I mean, it is a subset of the SOAP message payload XML

Vitor wrote:

Why? If it's XML, why do you want (or need) to manipulate it as a string?

Once this xml is in plain text, I need to convert it to base64 and send it to another web service. That's why I need this xml as a plain text

Do you have any ideas???

Thanks
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Thu Jan 31, 2013 10:22 am    Post subject: Reply with quote

Jedi Knight

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

If you would attend the required training class, you would be engaged by an instructor who would walk you through creating an Environment XMLNSC structure, which when complete, would be the XML you want. You then use RootBitStream to create a STRING that can be used in an OutputRoot to a file node to write the XML to disk (or a SoapRequest node to the web service if you prefer).

But since you have not attended that class....
_________________
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
mqjeff
PostPosted: Thu Jan 31, 2013 11:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You certainly would never use RootBitstream to serialize a section of an input message.

There's no apparent need to move the message into environment in the first place.

There's no apparent need to write custom code to EXTRACT a SOAP body.

But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Thu Jan 31, 2013 11:32 am    Post subject: Reply with quote

Jedi Knight

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

mqjeff wrote:
You certainly would never use RootBitstream to serialize a section of an input message.


I never said you would. What I said was, construct an XMLNSC tree in Environment, then use RootBitStream on that tree to create a CHARACTER STRING, as is the goal of the OP.

mqjeff wrote:
There's no apparent need to move the message into environment in the first place.


No one is moving anything. You are creating an entirely new tree, according to the format desired. The OP wants to edit the incoming data to a new tree format.

mqjeff wrote:
But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.


It works, and is an exercise from the class. For example, taking an InputRoot.SOAP.Body subset of elements and creating an output file with XML or PDF format.
_________________
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
broly
PostPosted: Thu Jan 31, 2013 11:39 am    Post subject: Reply with quote

Newbie

Joined: 02 Aug 2012
Posts: 6

mqjeff wrote:

But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.


Mqjeff, what is the correct option I have to specify using ASBITSTREAM?. What I worry about all of this is that given this xml.

Code:

<custom-xml id="temporal" data="ok">
    <some-tag>some value</some-tag>
</custom-xml>


After the transformation to text, becomes:

Code:

<custom-xml>
    <id>temporal</id>
    <data>ok</data>
    <some-tag>some value</some-tag>
</custom-xml>


All the attributes are converted to elements. What is the correct option to avoid this behavior.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jan 31, 2013 11:46 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

broly wrote:
mqjeff wrote:

But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.


Mqjeff, what is the correct option I have to specify using ASBITSTREAM?. What I worry about all of this is that given this xml.

It's the option that is not RootBitstream.

broly wrote:
All the attributes are converted to elements. What is the correct option to avoid this behavior.

Don't stick it in Environment. Use InputRoot directly.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jan 31, 2013 1:14 pm    Post subject: Reply with quote

Grand High Poobah

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

@ broly

mqjeff wrote:

But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.


And remember that by default the Environment tree has no parser attached.
So unless you defined one to the branch you're attaching your stuff, moving your stuff to the Environment will change your attributes...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
broly
PostPosted: Thu Jan 31, 2013 1:57 pm    Post subject: Reply with quote

Newbie

Joined: 02 Aug 2012
Posts: 6

Thanks to all.

It works, I moved the message from Environment to InputRoot and now the attributes are not converted to elements anymore.
.
Back to top
View user's profile Send private message
kash3338
PostPosted: Thu Jan 31, 2013 4:47 pm    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

broly wrote:

It works, I moved the message from Environment to InputRoot and now the attributes are not converted to elements anymore.


It is more clear when you say, you never moved your InputRoot to Environment and had directly used your InputRoot in the ASBITSTREAM function. You can never move/populate stuff into InputRoot object/reference.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Fri Feb 01, 2013 5:21 am    Post subject: Reply with quote

Jedi Knight

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

fjb_saper wrote:
mqjeff wrote:

But given all that, as long as the message tree is properly stored in Environment to retain it's XMLNSC nature, there's no reason that ASBITSTREAM with the correct option won't work.


And remember that by default the Environment tree has no parser attached.
So unless you defined one to the branch you're attaching your stuff, moving your stuff to the Environment will change your attributes...


If you read my post carefully, you will notice I initialize my Environment assigments under the XMLNSC parser attribute.

How is the OP supposed to edit the InputRoot structure to modify its format?

Are you suggesting its easier to edit a character string to format XML data rather than have the data in a proper tree structure and let the XMLNSC parser create the proper XML structure to send to the web service?

As per the documentation:

Quote:
RootBitStream, the algorithm that generates the bit stream is the same as that used by an output node. In this mode, a meaningful result is obtained only if the element pointed to is at the head of a subtree with an appropriate structure.


For example:

Code:
  DECLARE options INTEGER BITOR( ValidateNone, RootBitStream );
  SET InputMessageData = ASBITSTREAM( Environment.Root.XMLNSC OPTIONS options );

_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER


Last edited by lancelotlinc on Fri Feb 01, 2013 6:15 am; edited 3 times in total
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Fri Feb 01, 2013 5:31 am    Post subject: Reply with quote

Grand High Poobah

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

lancelotlinc wrote:
fjb_saper wrote:
@ broly


If you read my post carefully, you will notice I initialize my Environment assigments under the XMLNSC parser attribute.

How is the OP supposed to edit the InputRoot structure to modify its format?


Didn't know your new nickname was broly! Thanks for clearing that up.
_________________
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 » Convert an XML from the InputRoot, into a plain xml
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.