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 » Converting incoming XML into String

Post new topic  Reply to topic
 Converting incoming XML into String « View previous topic :: View next topic » 
Author Message
paranoid221
PostPosted: Thu Aug 21, 2008 10:37 am    Post subject: Converting incoming XML into String Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 101
Location: USA

Greetings Gentle(men/women)
Iam little stuck at this point and could possibly use some guidance. I have an incoming XML that looks as follows:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<p:WSResponse xmlns:p="http://www.ibm.com/NS1">
<webReturn>
<webRtrnCd>0</webRtrnCd>
<webRtrnMsgs/>
<locationCd>1</locationCd>
<tcCode xsi:nil="true"/>
</webReturn>
</p:WSResponse>
</soapenv:Body>
</soapenv:Envelope>

and I need to convert this into a String. So my output message should look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<m:outXML xmlns:m="http://www.ibm.com/NmSP1">
<webReturn xsi:type = "xsd:string">'<webRtrnCd>0</webRtrnCd> <webRtrnMsgs/><locationCd>1</locationCd><tcCode xsi:nil="true"/>'</webReturn>
</p:outXML>
</soapenv:Body>
</soapenv:Envelope>

I have been struggling to accomplish this. I have attempted the following:
a) Copied InputRoot.XMLNSC into Environment.Variables.tempPayload (also did Create FIRSTCHILD of Environment DOMAIN 'BLOB' Name 'Variables'), tried to CAST the Environment.Variables.tempPayload as character with ENCODING 273, CCSID 437. RESULT: Output Message has empty Body
b)SET OutputRoot.XMLNSC = InputRoot....WebReturn;
tempBLOB = ASBITSTREAM(OutputRoot.XMLNSC, 546, 437)
tempCHAR = CAST(tempBLOB AS CHARACTER CCSID 437 ENCODING 546)
SET OutputRoot.XMLNSC = NULL;
SET OutputRoot.XMLNSC.....outXML.webReturn = tempCHAR
(NOTE: I've taken care to set the namespaces for envelopes and body etc correctly.)

RESULT:
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'SET tempBLOB = ASBITSTREAM(OutputRoot.XMLNSC ENCODING 546 CCSID 437);'
)
(0x01000000):ParserException = (
(0x03000000):File = '/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCParser.cpp'
(0x03000000):Line = 673
(0x03000000):Function = 'ImbXMLNSCParser::refreshBitStreamFromElementsCommon'
(0x03000000):Type = 'ComIbmWSInputNode'
(0x03000000):Name = 'ECS_ELR_TO_TPAR/VBToTPARMsgTransform_MsgFlow#FCMComposite_1_1'
(0x03000000):Label = 'ECS_ELR_TO_TPAR.VBToTPARMsgTransform_MsgFlow.receiveRequestFromVB_HTTP Input'
(0x03000000):Catalog = 'BIPv610'
(0x03000000):Severity = 3
(0x03000000):Number = 5010
(0x03000000):Text = 'XML Writing Errors have occurred'
(0x01000000):ParserException = (
(0x03000000):File = '/build/S610_P/src/MTI/MTIforBroker/GenXmlParser4/ImbXMLNSCWriter.cpp'
(0x03000000):Line = 877
(0x03000000):Function = 'ImbXMLNSCWriter::writeMisc'
(0x03000000):Type = ''
(0x03000000):Name = ''
(0x03000000):Label = ''
(0x03000000):Catalog = 'BIPv610'
(0x03000000):Severity = 3
(0x03000000):Number = 5016
(0x03000000):Text = 'Unexpected XML type at this point in document.'
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'webRtrnMsgs'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'folderType'

Iam not sure how I should go about resolving this error. Thought some enlightened soul here would have a better idea and point me in the right direction.


Last edited by paranoid221 on Thu Aug 21, 2008 9:41 pm; edited 2 times in total
Back to top
View user's profile Send private message
paranoid221
PostPosted: Thu Aug 21, 2008 12:54 pm    Post subject: Converting incoming XML into String Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 101
Location: USA

OK I may have made a little progress on this.
I'm now able to get the output message but not in the way I wanted.
Here is what it looks like :
<SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAPENV:Body>
<m:outXML xmlns:m="http://www.ibm.com/NmSP1"> SOAPENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<webReturn xsi:type "xsd:string">&lt;webRtrnCd&gt;0&lt;/webRtrnCd&gt;&lt;webRtrnMsgs/&gt;&lt;locationCd&gt;1&lt;/locationCd&gt;&lt;tcCode xmlns:NS2=&quot;http://www.w3.org/2001/XMLSchema-instance&quot
</p:outXML>
</soapenv:Body>
</soapenv:Envelope>

Did I mess something up with the encodings and codepages? I have tried quite a good number of combinations to no avail. Any guidance appreciated.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Aug 21, 2008 1:04 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

First question: since you are using v6.1, why are you not using the SOAP domain to parse your input message?

Try this:
Code:
SET OutputRoot.XMLNSC.m:outXML = ASBITSTREAM( InputRoot.XMLNSC.soap:Envelope.soap:Body.prefix:WSResponse.webReturn
  OPTIONS FolderBitStream
  ENCODING InputRoot.Properties.Encoding
  CCSID InputRoot.Properties.CodedCharSetId );
It is not tested code, and it uses namespace prefixes which I invented in order to remind you that you need to DECLARE your own prefixes for use in the ESQL.
Back to top
View user's profile Send private message
paranoid221
PostPosted: Thu Aug 21, 2008 2:19 pm    Post subject: Converting incoming XML into String Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 101
Location: USA

Hey kimbert,
Iam using the 6.1 toolkit but our server runtimes are still at 6.0.2. We have only 1 6.1 runtime in one of the sandbox servers where Iam deploying and testing right now. All the other testing environments are at 6.0.2. The direction right now is to not use any nodes/components that would require 6.1 runtime.
They only install the toolkits on our machines and not the runtimes and hence I cannot test anything locally.
Iam told that the upgrades to the runtimes are just around the corner maybe in a month or two but here comes a project team with kind of a rush-priority request and wants to get this flow done for them in 11 days.
I'll try what you suggested and see how it does for me.
Meanwhile I was just thinking if something like this would work:

SET Environment.Variables.myMsg = InputRoot.XMLNSC......Body.WSRESPayload;

SET OutputRoot.XMLNSC....Body.outXML = Environment.Variables.myMsg;
SET OutputRoot.XMLNSC....Body.outXML.(XMLNSC.Attribute)xsi:type='xsd:string';

Just a thought remotely in my mind...please weigh in with your thoughts.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 21, 2008 5:29 pm    Post subject: Reply with quote

Grand High Poobah

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

I think that's exactly what you're looking for. Have you tried it?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
paranoid221
PostPosted: Thu Aug 21, 2008 9:16 pm    Post subject: Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 101
Location: USA

Voila,
Thanks Kimbert and saper for jumping in.
The thought I had lingering in my mind has finally worked.
SET Environment.Variables.myMsg = InputRoot.XMLNSC......Body.WSRESPayload;

SET OutputRoot.XMLNSC....Body.outXML = Environment.Variables.myMsg;
SET OutputRoot.XMLNSC....Body.outXML.(XMLNSC.Attribute)xsi:type='xsd:string';

Kimbert, I did try what you've suggested once and I got some error-don't exactly remember (been heck of a work week this).
Let me make these project team folks happy for once and then I'll try to play a little bit more around your suggestion. It'd probably help me for another interface.
On a personal note, is Jonathan Lowe still at IBM Hursley?? Last time I was on a call with him (late last year), he had plans of quitting IBM!!
_________________
LIFE is a series of complex calculations, somewhere multiplied by ZERO.
Back to top
View user's profile Send private message
fschofer
PostPosted: Fri Aug 22, 2008 12:02 am    Post subject: Reply with quote

Knight

Joined: 02 Jul 2001
Posts: 524
Location: Mainz, Germany

Hi

Quote:
<SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAPENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAPENV:Body>
<m:outXML xmlns:m="http://www.ibm.com/NmSP1"> SOAPENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<webReturn xsi:type "xsd:string">&lt;webRtrnCd&gt;0&lt;/webRtrnCd&gt;&lt;webRtrnMsgs/&gt;&lt;locationCd&gt;1&lt;/locationCd&gt;&lt;tcCode xmlns:NS2=&quot;http://www.w3.org/2001/XMLSchema-instance&quot
</p:outXML>
</soapenv:Body>
</soapenv:Envelope>


Your sample above shows the only valid way to store XML as a string within a XML element or attribute. The masking of '<' and '>' is needed there.

If you want to store the XML 1:1 you have to use a CDATA section.
http://www.w3schools.com/xml/xml_cdata.asp

Greetings
Frank
Back to top
View user's profile Send private message Send e-mail
paranoid221
PostPosted: Tue Sep 02, 2008 9:19 am    Post subject: Reply with quote

Centurion

Joined: 03 Apr 2006
Posts: 101
Location: USA

Hi fschofer,

The Webservice response method signature is a string which in my example is the <outXML>. Now if I say ...
SET OutputRoot.XMLNSC....Body.outXML.(XMLNSC.CDataField) = Environment.Variables.myMsg;
That to me is an error since the webservice expects outXML to be a string.
How do I solve this fix then?
_________________
LIFE is a series of complex calculations, somewhere multiplied by ZERO.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Sep 02, 2008 9:33 am    Post subject: Reply with quote

Grand High Poobah

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

paranoid221 wrote:
Hi fschofer,

The Webservice response method signature is a string which in my example is the <outXML>. Now if I say ...
SET OutputRoot.XMLNSC....Body.outXML.(XMLNSC.CDataField) = Environment.Variables.myMsg;
That to me is an error since the webservice expects outXML to be a string.
How do I solve this fix then?

If your expected string is well formed xml you will have 2 different manifestations:
a) with CData [[<xml.......]]
b) with element &ltxml .....&gt or escaped xml content.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Tue Sep 02, 2008 11:15 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
How do I solve this fix then?

If you want to output a CDATA section, read this: http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/topic/com.ibm.etools.mft.doc/ac67174_.htm
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Converting incoming XML into String
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.