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 » Assigning the entire input XML message to an output element

Post new topic  Reply to topic Goto page 1, 2  Next
 Assigning the entire input XML message to an output element « View previous topic :: View next topic » 
Author Message
selenneg
PostPosted: Fri Jun 24, 2011 3:41 pm    Post subject: Assigning the entire input XML message to an output element Reply with quote

Newbie

Joined: 24 Jun 2011
Posts: 5

Hi everybody

I'm working with an older version of MQSI (v 2.0.2) and I wan to assign the input XML message as part of output message. I mean, the input is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<genericResponse name = "success" >
<acknowledge>
<com:description>Operation success.</com:description>
</acknowledge>
<result>
<enterprise>
<enterpriseName>Aprov1600</enterpriseName>
</enterprise>
</result>
</genericResponse>

And I want an output message like:

<?xml version="1.0" encoding="UTF-8"?>
<GenericResponse>
<EnterpriseName>Aprov1600</EnterpriseName>
<Error_description>Operation success. </Error_description>
<XML_MESSAGE><?xml version="1.0" encoding="UTF-8"?>
<genericResponse name = "success" >
<acknowledge>
<com:description>Operation success.</com:description>
</acknowledge>
<result>
<enterprise>
<enterpriseName>Aprov1600</enterpriseName>
</enterprise>
</result>
</genericResponse>
</XML_MESSAGE>
</GenericResponse>

And my esql code is something like this:

SET OutputRoot.Properties.MessageFormat = 'XML';
SET OutputRoot."XML".(XML.XmlDecl)= ' ';
SET OutputRoot."XML".(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot."XML".(XML.XmlDecl).(XML.Encoding) = 'UTF-8';

SET OutputRoot.XML.GenericResponse.EnterpriseName = InputRoot.XML.genericResponse.result.enterprise.enterpriseName
SET OutputRoot.XML.GenericResponse.Error_description = InputRoot.XML.genericResponse.acknowledge."com:description";

SET OutputRoot.XML.GenericResponse.XML_MESSAGE = CAST(InputRoot.XML.GenericResponse.* AS CHAR);

But it's not working....I appreciate your suggestios.

Regards,
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 24, 2011 7:46 pm    Post subject: Reply with quote

Grand High Poobah

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

I don't believe the embedded XML declaration is legal XML...
AFAIK you're only allowed 1 XML declaration per document and it has to be at the start of the document...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Fri Jun 24, 2011 10:39 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

{getting in before any of the Hursley Guys are awake...}

Why oh why oh Why are you using the deprecated XML domain.

You should be using the XMLNSC domain.


_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Jun 24, 2011 11:56 pm    Post subject: Reply with quote

Grand High Poobah

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

smdavies99 wrote:
{getting in before any of the Hursley Guys are awake...}

Why oh why oh Why are you using the deprecated XML domain.

You should be using the XMLNSC domain.


selenneg wrote:
I'm working with an older version of MQSI (v 2.0.2)

Because he is running on a way way way out of support version that does not have the XMLNS or XMLNSC domains??
I guess you missed your dose of cafeine and skipped that part...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Sat Jun 25, 2011 1:29 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Quote:
Because he is running on a way way way out of support version that does not have the XMLNS or XMLNSC domains??

not the lack of cafeine, more of a case of too much Pimms in SW19 last night.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Sat Jun 25, 2011 3:48 am    Post subject: Re: Assigning the entire input XML message to an output elem Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

Please put [code] tags around XML messages and ESQL; it's much easier to read that way.

selenneg wrote:
I'm working with an older version of MQSI (v2.0.2)

v2.0.2 was the latest version of MQSI; IBM renamed the product after that. Does "older version" mean "latest fixpack not applied"?

If the out-of-support status is not incentive enough to upgrade, there may be other reasons:

selenneg wrote:
Code:
SET OutputRoot.XML.GenericResponse.Error_description = InputRoot.XML.genericResponse.acknowledge."com:description";
SET OutputRoot.XML.GenericResponse.XML_MESSAGE = CAST(InputRoot.XML.GenericResponse.* AS CHAR);

  • The XML parser doesn't support element names with colons.
  • The CAST function doesn't serialize the input message. Use the (not-yet-deprecated) BITSTREAM function instead, or use the BLOB parser to read the input message.
  • The CAST function also doesn't yet support a CCSID parameter to conveniently convert bitstreams to character strings, so consider using a CDATA section, with hex-binary encoding for the embedded message.

selenneg wrote:
But it's not working....I appreciate your suggestions.

"not working" is a bit vague. Be more specific.
Back to top
View user's profile Send private message
selenneg
PostPosted: Tue Jun 28, 2011 9:54 am    Post subject: Assigning the entire input XML message to an output element Reply with quote

Newbie

Joined: 24 Jun 2011
Posts: 5

Hi again,

I was sick but i'm back.

I made this modification in the esql code:

original:
Code:
SET OutputRoot.XML.GenericResponse.XML_MESSAGE = CAST(InputRoot.XML.GenericResponse.* AS CHAR);


now:
Code:
SET OutputRoot.XML.GenericResponse.XML_MESSAGE = CAST(BITSTREAM(InputRoot.XML.*) AS CHAR);


An the output looks like:
Code:
<?xml  version="1.0" encoding="UTF-8"?>
<GenericResponse>
<EnterpriseName>Aprov1600</EnterpriseName>
<Error_description>Operation Success.</Error_description>
<XML_MESSAGE>X&apos;3c3f786d6c2076657273696f6e3d22312e3022206
56e636f64696e673d225554462d38223f3e3c67656e65726963526573706f6e
7365206e616d65203d20227375636365737322203e3c61636b6e6f776c6564
67653e3c636f6d3a6465736372697074696f6e3e4f7065726174696f6e20737
563636573732e3c2f636f6d3a6465736372697074696f6e3e3c2f61636b6e6f7
76c656467653e3c726573756c743e3c656e74657270726973653e3c656e746
57270726973654e616d653e4170726f76313630303c2f656e7465727072697
3654e616d653e3c2f656e74657270726973653e3c2f726573756c743e3c2f67
656e65726963526573706f6e73653e&apos;</XML_MESSAGE>
</GenericResponse>


But I don't know how to get the embedded xml decoded, not as a bit message.



Thks again for your time.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 28, 2011 10:02 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447


Don't use BITSTREAM.

Use ASBITSTREAM.

Then CAST it to a CHARACTER in a *specific* CCSID.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jun 28, 2011 10:04 am    Post subject: Reply with quote

Grand High Poobah

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

mqjeff wrote:

Don't use BITSTREAM.

Use ASBITSTREAM.

Then CAST it to a CHARACTER in a *specific* CCSID.


Was ASBITSTREAM available in mqsi V 2.x?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Tue Jun 28, 2011 10:12 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

fjb_saper wrote:
Was ASBITSTREAM available in mqsi V 2.x?






Back to top
View user's profile Send private message
rekarm01
PostPosted: Tue Jun 28, 2011 10:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

mqjeff wrote:
Then CAST it to a CHARACTER in a *specific* CCSID.

More importantly, the CAST CCSID parameter wasn't available in MQSI v2.0.x either.
Back to top
View user's profile Send private message
selenneg
PostPosted: Tue Jun 28, 2011 11:20 am    Post subject: Reply with quote

Newbie

Joined: 24 Jun 2011
Posts: 5

Exactly. I'm very limited because we are working with a very old version. But, believe me, it not depens of me.

So, that's why i'm looking for

I really appreciate your suggestions.

Thanks a lot.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jun 28, 2011 11:24 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

So at least in 2.1, the way to do this WAS to use BITSTREAM to generate a BLOB string.

You then just cast this to character to ensure that it was represented as real characters rather than as x'0a0a01' representation.

Which is what the code you have does.

But you might try breaking it apart into separate set statements to separate variables.

Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Jul 01, 2011 3:05 am    Post subject: Re: Assigning the entire input XML message to an output elem Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

There are several different options, one of which may work:
  • The CAST function won't "decode" the bitstream as a string, but the MRM parser might. Use the MRM domain with XML physical format for OutputRoot, and construct a message set, where <XML_MESSAGE> is hexbinary.
  • Implement a custom node to convert the bitstream to a string.
  • MQSI v2.0.x doesn't support declaring procedures, functions or reference variables, so it's not possible to recursively traverse the input message and manually reconstruct it as a string. However, if the structure of the input message is somewhat predictable, it ought to be possible to write a sequence of iterative statements to do much the same thing.
  • Use SUBSTRING to extract pairs of bytes from the bitstream, and a really big CASE statement to manually convert them to characters, one at a time. (That approach is much less practical for UTF-8 than it would be for ASCII, not that it's all that practical for ASCII.)
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Jul 01, 2011 3:31 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Quote:

Use SUBSTRING to extract pairs of bytes from the bitstream, and a really big CASE statement to manually convert them to characters, one at a time.


I've seen that in use at an Airline site I once visited. Their flows were written for 2.1 and the person who migrated them to V6.1 didn't bother to change the code....
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
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 » Assigning the entire input XML message to an output element
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.