Author |
Message
|
max power |
Posted: Thu Sep 06, 2007 8:24 am Post subject: Compute Node problems |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
Hi, I'm a complete newbie so please be nice.
I am trying to use the compute node for the first time and am having a few problems which I can't work out.
I put this message on the input node:
<?xml version="1.0 encoding="UTF-8"?>
<Message>
<Firstname>MAX</Firstname>
<Surname>POWER</Surname>
<House_no>13</House_no>
<Postcode>SW191XX</Postcode>
</Message>
I set the message domain to XMLNS.
My compute node reads as follows:
CREATE COMPUTE MODULE XML_XFER_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
CALL CopyEntireMessage();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER;
DECLARE J INTEGER;
SET I = 1;
SET J = 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.Message.Firstname = InputRoot.XML.Message.Firstname;
SET OutputRoot.XML.Message.Surname = 'Smith';
END;
END MODULE;
(all I want to output is the first name and change the surname to 'Smith'. This is just a simple test on how the compute node works).
The unchanged message is sent straight out via the 'Failure' terminal and I don't get any errors in the log.
I bet I'm doing something stupid but I can't seem to work it out.
Can anyone help?
edit: I am using rfhutil to put this message on the input queue and am on a WinXP environment. |
|
Back to top |
|
 |
Krayvyn |
Posted: Thu Sep 06, 2007 8:46 am Post subject: |
|
|
Novice
Joined: 08 Jun 2005 Posts: 12
|
Looks good for your first time.
Remember calling CopyMessageHeaders() and CopyEntireMessage() is redundant. You probably just want CopyMessageHeaders in your case.
How did you set the Message Domain to XMLNS? On the input node?
What output are you getting? What version are you using?
At first glance your code looks good. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Sep 06, 2007 10:21 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay, it looks like you've change the implementation of CopyEntireMessage().
This is bad, as it will confuse everyone who ever has to change your code.
Restore the original contents - or delete the whole esql file and start again.
Then put your specific code directly in the Main function - after calling ONLY CopyMessageHeaders OR CopyEntireMessage.
And if your Domain is XMLNS, then you need to Set OutputRoot.XMLNS... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
asudhakar |
Posted: Thu Sep 06, 2007 10:37 pm Post subject: |
|
|
 Centurion
Joined: 12 May 2007 Posts: 116 Location: Bangalore
|
Ur code was running successfully.
Just check it.
CREATE COMPUTE MODULE JsMFlow_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.Message.Firsname = InputRoot.XML.Message.Firstname;
SET OutputRoot.XML.Message.Surname = 'Smith';
END;
END MODULE;
Message Flow : MQInput -> Comput -> MQOutput.
MQInput node Message domain property : XML
(prefer XMLNS domain.)
Input : <Message><Firstname>MAX</Firstname><Surname>POWER</Surname><House_no>13</House_no><Postcode>SW191XX</Postcode></Message>
Output :
<Message><Firsname>MAX</Firsname><Surname>Smith</Surname></Message> _________________ WebSphere MQ, MB Support and Admin |
|
Back to top |
|
 |
max power |
Posted: Fri Sep 07, 2007 1:19 am Post subject: |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
Thanks for the help people. I've got it working now.
However, that is a simple test of the compute node over, now for the more detailed ESQL.  |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 07, 2007 3:43 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm sorry, your code is still wrong.
You are using XML domain, and not XMLNS or XMLNSC.
This is bad. Use XMLNS or XMLNSC. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
max power |
Posted: Fri Sep 07, 2007 4:39 am Post subject: |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
Hi Jeff,
I am now using XMLNS. That's one of the changes I did to get it working.
Thanks. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Sep 07, 2007 4:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Okay, I saw asudhakar's code, and figured you were using that. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
max power |
Posted: Mon Sep 10, 2007 12:43 am Post subject: |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
I have another issue now. My compute node seems to be working without any problems unless I try and extract data from an XML tag that contains a description.
How would I extract data from the below XML..?
<XMLTag Description = "Text" DATA:LineType="1">
<Data>TEST</Data>
</XMLTag>
I assume this has something to do with namespaces but if I use the ESQL below, I don't seem to get any data back:
SET OutputRoot.XMLNS.Test.Data = InputRoot.XMLNS.XMLTag.Data;
This code does not populate any data and the field Test>Data is left out of the Output message. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 10, 2007 2:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
max power wrote: |
How would I extract data from the below XML..?
<XMLTag Description = "Text" DATA:LineType="1">
<Data>TEST</Data>
</XMLTag>
I assume this has something to do with namespaces but if I use the ESQL below, I don't seem to get any data back:
SET OutputRoot.XMLNS.Test.Data = InputRoot.XMLNS.XMLTag.Data;
This code does not populate any data and the field Test>Data is left out of the Output message. |
Have you tried
Code: |
SET OutputRoot.XMLNS.Test.Data = InputRoot.XMLNS.*:XMLTag.Data; |
The other option to check is whether XMLTag is a legal element in XML.
Use a trace node before your compute node and show us the output...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
max power |
Posted: Mon Sep 10, 2007 2:36 am Post subject: |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
I'm not actualling using 'XML Tag', this is just used as an example.
I'll try what you've suggested though.
UPDATE:
The '.*:' hasn't appeared to do anything.
The actual data I want to extract is the field ItemID from the XML below:
<Transaction>
<RetailTransaction Version="1.0" TransactionStatus="Status">
<LineItem EntryMethod="Input" ABMN:LineType="1">
<Sale>
<Identity Type="MAP">
<ItemID>12345678</ItemID>
</Identity>
</Sale>
</LineItem>
</RetailTransaction>
</Transaction>
If I use the code SET OutputRoot.XMLNS.Header.Item.Data = InputRoot.XMLNS.Transaction.*:RetailTransaction.LineItem.Sale.Identity.ItemID, nothing is returned, not even the Output field. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 10, 2007 3:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
SET OutputRoot.XMLNS.Header.Item.Data = InputRoot.XMLNS.*:Transaction.*:RetailTransaction.*:LineItem.*:Sale.*:Identity.*:ItemID;
As I said, show us the output of the trace node...
May be the message is not what you think it is? _________________ MQ & Broker admin |
|
Back to top |
|
 |
max power |
Posted: Mon Sep 10, 2007 4:56 am Post subject: |
|
|
Apprentice
Joined: 06 Sep 2007 Posts: 31
|
Yep, that's worked now. Thanks very much.  |
|
Back to top |
|
 |
bdrummond |
Posted: Mon Sep 10, 2007 5:17 am Post subject: |
|
|
Disciple
Joined: 06 May 2004 Posts: 164
|
Not the same problem but I thought I'd put it in here....
How do I use part of an XML tag in my IF statement?
EG,
If my XML tag is : <DATA Mode="Message">1</DATA>
How would I write an IF statement using the Mode="Message" as part of my statment?
ie, IF Mode='Message'
SET OutputRoot.Text = 'New';
ELSE
SET OutputRoot.Text = 'Old';
END IF; |
|
Back to top |
|
 |
Vitor |
Posted: Mon Sep 10, 2007 5:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Identify "Mode" as an XML Attribute rather than the default of Element. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|