Author |
Message
|
jfecq |
Posted: Wed Feb 27, 2013 6:54 pm Post subject: Output as XML message |
|
|
Apprentice
Joined: 24 Sep 2012 Posts: 36
|
Hi, I need to use broker to output a XML message to a remote queue. Using ESQL,
Code: |
-- this?
SET OutputRoot."BLOB"."BLOB" = xmlAsBlob;
-- or this?
SET OutputRoot.XMLNSC = xmlString;
|
which one should I use? Or both are incorrect?
Because if I use
Code: |
SET OutputRoot.XMLNSC = xmlString; |
I got the error
No root element was found while writing the XML message.
xmlString is a standard xml as below.
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<A>1</A>
<B><C>2</C></B>
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 27, 2013 9:51 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Broker 101
SET OutputRoot.XMLNSC.(somestuff) expects the XML to be in form of a message tree.
SET OutputRoot.BLOB.BLOB will take any content for the BLOB value. It will essentially hold a BITSTREAM...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jfecq |
Posted: Wed Feb 27, 2013 9:55 pm Post subject: |
|
|
Apprentice
Joined: 24 Sep 2012 Posts: 36
|
Therefore I should used SET OutputRoot.BLOB.BLOB? Since the other party expects the whole xml including <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Feb 27, 2013 10:01 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jfecq wrote: |
Therefore I should used SET OutputRoot.BLOB.BLOB? Since the other party expects the whole xml including <?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
Make sure the BLOB is in UTF-8 and the message properties show CCSID = 1208.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
jfecq |
Posted: Wed Feb 27, 2013 10:18 pm Post subject: |
|
|
Apprentice
Joined: 24 Sep 2012 Posts: 36
|
These are enough?
Code: |
SET OutputRoot.Properties.CodedCharSetId=1208;
SET OutputRoot.MQMD.CodedCharSetId = 1208;
DECLARE xmlAsBlob BLOB CAST(InputRoot.SOAP.Body.xml AS BLOB CCSID(1208));
|
Thanks! |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Feb 28, 2013 4:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
jfecq wrote: |
These are enough?
Code: |
SET OutputRoot.Properties.CodedCharSetId=1208;
SET OutputRoot.MQMD.CodedCharSetId = 1208;
DECLARE xmlAsBlob BLOB CAST(InputRoot.SOAP.Body.xml AS BLOB CCSID(1208));
|
Thanks! |
No.
That won't do anything.
And, no, you DO NOT NEED TO DO THIS to send to an MQOutput node.
The MQOutput node is perfectly capable of taking any kind of logical message tree and using the necessary properties and parser to convert it to a physical message. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Feb 28, 2013 5:52 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Feb 28, 2013 6:09 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Thanks, I knew you'd pick up the training reference!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Feb 28, 2013 6:15 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
jfecq |
Posted: Thu Feb 28, 2013 5:51 pm Post subject: |
|
|
Apprentice
Joined: 24 Sep 2012 Posts: 36
|
mqjeff wrote: |
No.
That won't do anything.
And, no, you DO NOT NEED TO DO THIS to send to an MQOutput node.
The MQOutput node is perfectly capable of taking any kind of logical message tree and using the necessary properties and parser to convert it to a physical message. |
So I will just only need to code this?
SET OutputRoot."BLOB"."BLOB" = xmlAsBlob; |
|
Back to top |
|
 |
rekarm01 |
Posted: Fri Mar 01, 2013 2:32 am Post subject: Re: Output as XML message |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
jfecq wrote: |
Hi, I need to use broker to output a XML message to a remote queue. Using ESQL,
Code: |
-- this?
SET OutputRoot."BLOB"."BLOB" = xmlAsBlob;
-- or this?
SET OutputRoot.XMLNSC = xmlString; |
|
The "BLOB" doesn't need double-quotes. The choice of parser only affects the internal representation of the parsed message. Both the BLOB and XMLNSC parsers can output an XML message; it should look the same either way. But the XMLNSC parser can also ensure that output messages are well-formed, and validate them against a schema.
jfecq wrote: |
Because if I use
Code: |
SET OutputRoot.XMLNSC = xmlString; |
I got the error
No root element was found while writing the XML message. |
The documentation describes the XMLNSC logical message tree structure in more detail. Simply assigning an unparsed character string won't work. |
|
Back to top |
|
 |
joebuckeye |
Posted: Fri Mar 01, 2013 6:51 am Post subject: Re: Output as XML message |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
jfecq wrote: |
Because if I use
Code: |
SET OutputRoot.XMLNSC = xmlString; |
I got the error
No root element was found while writing the XML message.
xmlString is a standard xml as below.
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<A>1</A>
<B><C>2</C></B>
|
|
Your xmlString variable does not contain valid XML. That is probably why you got the 'No root element was found' error. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Mar 01, 2013 6:54 am Post subject: Re: Output as XML message |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
joebuckeye wrote: |
jfecq wrote: |
Because if I use
Code: |
SET OutputRoot.XMLNSC = xmlString; |
I got the error
No root element was found while writing the XML message.
xmlString is a standard xml as below.
Code: |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<A>1</A>
<B><C>2</C></B>
|
|
Your xmlString variable does not contain valid XML. That is probably why you got the 'No root element was found' error. |
It's also a string not a message tree. This is not going to help. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Fri Mar 01, 2013 7:23 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
In order to be successful using Broker, you must learn and understand how to construct and manipulate logical message trees.
This is an entirely separate operation than working with physical messages.
Until you stop thinking about physical messages, and BLOBs and bitstreams, you will not start thinking about logical message trees.
It's certainly easy and possible to write code that will construct logical message trees from bitstreams, and construct bitstreams from logical message trees inside Broker.
None of the code you have posted makes any attempt to do that.
And it's usually not a necessary task to do either thing. |
|
Back to top |
|
 |
|