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 » Accessing the MQRFH2 header using a JavaCompute node

Post new topic  Reply to topic
 Accessing the MQRFH2 header using a JavaCompute node « View previous topic :: View next topic » 
Author Message
wyatt
PostPosted: Thu Nov 09, 2006 1:12 pm    Post subject: Accessing the MQRFH2 header using a JavaCompute node Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

Does anyone have an example of accessing user defined data in the MQRFH2 header?

The evaluateXPath() method defined in MbMessage and MbElement return data in the Message Body only.

Thx
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 09, 2006 1:28 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac30440_.htm


_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wyatt
PostPosted: Thu Nov 09, 2006 1:59 pm    Post subject: Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

I looked at the example in the suplied link(before posting), this link focuses is on the creation of an RFH2 header. We are trying to access an existing RFH2 header within java compute node, specifically user defined tags.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 09, 2006 2:16 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you look at the syntax of the XPath statement at the end of that section, it will show you (somewhat, there are some jsp formatting errors) how to write the XPath you want. Based on my reading, I would expect something like "/MQHRF2/usr/<property name>".

Otherwise, you can use the getFirstChild and getNextSibling methods on MbElement to work your way down from the Root to find the element named MQRFH2, and work your way down from there to the fields you want.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wyatt
PostPosted: Thu Nov 09, 2006 3:03 pm    Post subject: Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

Hmm, Im missing something
Quote:
Otherwise, you can use the getFirstChild and getNextSibling methods on MbElement to work your way down from the Root to find the element named MQRFH2, and work your way down from there to the fields you want.


The following code accesss the MQRFH2 folder but always returns empty list regardless of what is placed in the evaluateXPath method
MbElement inRoot = contact admin.getMessage().getRootElement();
MbElement inRFH2Doc = inRoot.getFirstChild().getNextSibling().getNextSibling();
java.util.List inRFH2 = (java.util.List) inRFH2Doc.evaluateXPath("/MQRFH2");
inRFH2.size();

When evaluateXPath is invoked from MbMessage, it finds XML tags in the message body but not anything that in the MQRFH2 folder
MbMessage msg = assembly.getMessage();
List chapters= (List)msg.evaluateXPath("/MQRFH2");
MbElement chapter = (MbElement)chapters.get(0);
The MbMessage java doc says MbMessage.evaluateXPath() "Evaluates the XPath 1.0 expression with the message body (last child of root) as the context node." Is MQRFH2 part of the message body within Java compute node?
Back to top
View user's profile Send private message
wyatt
PostPosted: Thu Nov 09, 2006 3:25 pm    Post subject: Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

ha, this works also but I dont think it will pass a code review:

MbElement inRFH2Doc = inRoot.getFirstChild().getNextSibling().getNextSibling().getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getFirstChild();
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Nov 09, 2006 3:28 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

MQRFH2 is going to be a Previous Sibling of the Message Body.

It's probably going to be the Next Sibling of MQMD.

Looking for /MQRFH2 after already moving to the second sibling of root doesn't make much sense.

Go back and look at the example in the documentation link again!

Ignore every statement that includes "create".
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wyatt
PostPosted: Thu Nov 09, 2006 3:43 pm    Post subject: Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

Quote:
Looking for /MQRFH2 after already moving to the second sibling of root doesn't make much sense.



Root->Properties->MQMD->MQRFH2
....getFirstChild(().getNextSibling().getNextSibling();

This takes you to the RFH2 folder

But as mentioned, evaluateXPath returns an empty list. Of course I can chain getNextSibling() methods

What else am I missing
Back to top
View user's profile Send private message
wyatt
PostPosted: Thu Nov 09, 2006 4:08 pm    Post subject: Reply with quote

Voyager

Joined: 28 Nov 2004
Posts: 76

For the benefit of others, this will retrieve data from RFH2 folder

MbElement root = inMessage.getRootElement();
MbXPath xp = new MbXPath("/MQRFH2/usr/sometag", root);
List rfh2list = (List)root.evaluateXPath(xp);
rfh2list.size();
MbElement rfh2elem = (MbElement) rfh2list.get(0);
rfh2elem.getName();
rfh2elem.getValue();

Thx, you were correct!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing the MQRFH2 header using a JavaCompute node
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.