Author |
Message
|
mq_crazy |
Posted: Tue Feb 22, 2005 2:01 pm Post subject: esql problem |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
I am trying to attach xml header to a message in the compute node, but the output doesn't comeout with the headers. Here is the ESQL used in the node:
CREATE COMPUTE MODULE NYPD_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
CALL CopyEntireMessage();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding") ='UTF-8';
SET OutputRoot.XML.(XML.XmlDecl).(XML.Standalone)='no';
SET OutputRoot=InputRoot;
END;
END MODULE;
Am i doing anything wrong?? |
|
Back to top |
|
 |
sieijish |
Posted: Tue Feb 22, 2005 2:09 pm Post subject: |
|
|
Acolyte
Joined: 29 Nov 2004 Posts: 67 Location: London
|
What headers are you expecting?
why are you doing
Quote: |
SET OutputRoot=InputRoot;
|
in CopyEntireMessage() |
|
Back to top |
|
 |
Michael Dag |
Posted: Tue Feb 22, 2005 2:10 pm Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
Try:
SET OutputRoot=InputRoot;
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version) = '1.0';
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding") ='UTF-8';
SET OutputRoot.XML.(XML.XmlDecl).(XML.Standalone)='no';
 _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 22, 2005 2:17 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why are you calling both CopyMessageHeaders and CopyEntireMessage? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mq_crazy |
Posted: Wed Feb 23, 2005 7:58 am Post subject: |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
This is my situation. I have mqinput node where i gave my messageset info. Domain as MRM, format as CWF1. My messageset has two formats CWF1 and XML1. I changed the message properties in compute node to change it to XML. The message comes out fine as XML. Now i need to attach a xml header, if i add that in compute node it gives error.
Please help. Here is my ESQL code..
CREATE COMPUTE MODULE IntegratedJustice_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
CALL CopyEntireMessage();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot=InputRoot;
SET OutputRoot.Properties.MessageFormat ='XML1';
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version)='1.0';
END;
END MODULE; |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 23, 2005 8:03 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jefflowrey wrote: |
Why are you calling both CopyMessageHeaders and CopyEntireMessage? |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mq_crazy |
Posted: Wed Feb 23, 2005 8:06 am Post subject: |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
shud i not copy both?? my intention is to copy whole message exactly and attach this extra header. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Feb 23, 2005 8:11 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you wish to add stuff to the front of the message, but after the headers, then you should only copy the headers, then add your new stuff, and then copy the rest of the input body.
This is basic use of the product and ESQL. ESQL constructs the output tree in the order that was specified. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
mq_crazy |
Posted: Wed Feb 23, 2005 8:25 am Post subject: |
|
|
 Master
Joined: 30 Jun 2004 Posts: 295
|
Thanks jeff for replying. Can you tell me how shud my ESQL code look like??? |
|
Back to top |
|
 |
javaforvivek |
Posted: Fri Feb 25, 2005 7:24 am Post subject: |
|
|
 Master
Joined: 14 Jun 2002 Posts: 282 Location: Pune,India
|
mq_dude wrote:
Quote: |
shud i not copy both?? my intention is to copy whole message exactly and attach this extra header.
|
Inserting the xml declaration is not same as inserting extra information in header.
Structure of any MQ Message is like this: MQ Message Discriptor (MQMD) + Optional RFH2 Header + Application data
Now if your Input Message is in XML domain but without the XML Declaration (<?xml version="1.0"?>), then you need to add this line in the application data and not in the MQMD..
So you can just call CopyEntireMessage and then write the code given by
MichaelDag.
I myself don't have access to WBIMB (I'm assuming that you are using WBIMB) right now, but I hope that the code will work well for you. _________________ Vivek
------------------------------------------------------
...when you have eliminated the impossible, whatever remains, however improbable, must be the truth. |
|
Back to top |
|
 |
jwende |
Posted: Tue Mar 01, 2005 2:19 pm Post subject: |
|
|
 Novice
Joined: 02 Jul 2001 Posts: 23
|
if your messageset has both renderings (CWF and XML), the output XML format will be written by the MRM XML writer component - I think this component doesn't care anything about your settings like
SET OutputRoot.XML = xyz;
it still ignores this as additional message tree information (because they are not defined in your message set).
You may consider changing the XML1 properties of your messageset to include some sort of XML header information. |
|
Back to top |
|
 |
|