Author |
Message
|
selenneg |
Posted: Fri Jun 24, 2011 3:41 pm Post subject: Assigning the entire input XML message to an output element |
|
|
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 |
|
 |
fjb_saper |
Posted: Fri Jun 24, 2011 7:46 pm Post subject: |
|
|
 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 |
|
 |
smdavies99 |
Posted: Fri Jun 24, 2011 10:39 pm Post subject: |
|
|
 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 |
|
 |
fjb_saper |
Posted: Fri Jun 24, 2011 11:56 pm Post subject: |
|
|
 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 |
|
 |
smdavies99 |
Posted: Sat Jun 25, 2011 1:29 am Post subject: |
|
|
 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 |
|
 |
rekarm01 |
Posted: Sat Jun 25, 2011 3:48 am Post subject: Re: Assigning the entire input XML message to an output elem |
|
|
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 |
|
 |
selenneg |
Posted: Tue Jun 28, 2011 9:54 am Post subject: Assigning the entire input XML message to an output element |
|
|
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'3c3f786d6c2076657273696f6e3d22312e3022206
56e636f64696e673d225554462d38223f3e3c67656e65726963526573706f6e
7365206e616d65203d20227375636365737322203e3c61636b6e6f776c6564
67653e3c636f6d3a6465736372697074696f6e3e4f7065726174696f6e20737
563636573732e3c2f636f6d3a6465736372697074696f6e3e3c2f61636b6e6f7
76c656467653e3c726573756c743e3c656e74657270726973653e3c656e746
57270726973654e616d653e4170726f76313630303c2f656e7465727072697
3654e616d653e3c2f656e74657270726973653e3c2f726573756c743e3c2f67
656e65726963526573706f6e73653e'</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 |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 10:02 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Tue Jun 28, 2011 10:04 am Post subject: |
|
|
 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 |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 10:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
Was ASBITSTREAM available in mqsi V 2.x?  |
 |
|
Back to top |
|
 |
rekarm01 |
Posted: Tue Jun 28, 2011 10:28 am Post subject: |
|
|
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 |
|
 |
selenneg |
Posted: Tue Jun 28, 2011 11:20 am Post subject: |
|
|
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 |
|
 |
mqjeff |
Posted: Tue Jun 28, 2011 11:24 am Post subject: |
|
|
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 |
|
 |
rekarm01 |
Posted: Fri Jul 01, 2011 3:05 am Post subject: Re: Assigning the entire input XML message to an output elem |
|
|
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 |
|
 |
smdavies99 |
Posted: Fri Jul 01, 2011 3:31 am Post subject: |
|
|
 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 |
|
 |
|