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 » MbXpath issue

Post new topic  Reply to topic
 MbXpath issue « View previous topic :: View next topic » 
Author Message
EAI Developer
PostPosted: Fri Feb 24, 2012 9:45 am    Post subject: MbXpath issue Reply with quote

Centurion

Joined: 30 Nov 2005
Posts: 101
Location: US

Hi All,
I am working with MbXpath on the xml meassge with namespaces, where expression is returning null(always) when evaluateXpath. I did work with MbXpath in the past, but without namespaces. I used altova xml spy and xpath checker to generate the expression, which is giving the value I want, but when I put the same in MbXpath it is not working. Can you please help me on this. Thanks !

Request Xml: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:feat="http://icm.xxx.com/soap/xxx" xmlns:com="http://icm.xxx.com/data/common" xmlns:set="http://icm.xxx.com/data/settings" xmlns:pres="http://icm.xxx.com/data/presence"><soapenv:Header/><soapenv:Body><feat:updateCurrentSettings><feat:sessionId com:SessionId="0332116575276"/>

Code:

MbXPath expr4 = new MbXPath("/soapenv:Envelope/soapenv:Body/feat:updateCurrentSettings/feat:sessionId/@com:SessionId");
expr4.addNamespacePrefix("feat","http://icm.xxx.com/soap/xxx");
expr4.addNamespacePrefix("com","http://icm.xxx.com/data/common");
expr4.addNamespacePrefix("set","http://icm.xxx.com/data/settings");
expr4.addNamespacePrefix("pres","http://icm.xxx.com/data/presence");

List list5 = (List)mRequest.evaluateXPath(expr4);
String sRequestMsg="";
if (!list5.isEmpty()) {

list5.size();
Iterator li = list5.iterator();
MbElement mEle = null;
while(li.hasNext()) {

mEle = (MbElement)li.next();
sRequestMsg = mEle.getValueAsString(); }
}

Here I am looking for the value of the attribute(com:SessionId) inside the xml tag <feat:sessionId>

I have even tried this : MbXPath expr4 = new MbXPath("//feat:sessionId/@*");

Message Broker v7.0.2 and on Windows Xp.
_________________
___________________
Regards,
EAI Developer.
Back to top
View user's profile Send private message Visit poster's website
lancelotlinc
PostPosted: Fri Feb 24, 2012 10:10 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

You may like using MessageSets with ESQL better than XPath. The toolkit provides namespace helps (CTRL+SPACE BAR) when using ESQL.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
EAI Developer
PostPosted: Fri Feb 24, 2012 10:27 am    Post subject: Reply with quote

Centurion

Joined: 30 Nov 2005
Posts: 101
Location: US

Hi,
I have to use java compute node, we do not use ESQL for some reason.

btw, in the below code snippet,

mRequest = globalEnv.getFirstElementByPath("./PCM/Request_xml") where i am setting the parser as "XMLNSC". stil no luck.
_________________
___________________
Regards,
EAI Developer.
Back to top
View user's profile Send private message Visit poster's website
lancelotlinc
PostPosted: Fri Feb 24, 2012 10:30 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Hahahahahaha.

Who made the decision to outlaw ESQL in your work site?

I went to the doctor once. I pointed at my hand. I said "it hurts when I do that." Doctor said, don't do that!
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Fri Feb 24, 2012 10:45 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

lancelotlinc wrote:
Who made the decision to outlaw ESQL in your work site?


I think we've done this to death on another thread. I know you enjoy throwing the same subject up until people agree with you, but we don't need this again.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Feb 24, 2012 10:49 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Vitor wrote:
lancelotlinc wrote:
Who made the decision to outlaw ESQL in your work site?


I think we've done this to death on another thread. I know you enjoy throwing the same subject up until people agree with you, but we don't need this again.


You have something against ESQL, Vitor?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Fri Feb 24, 2012 10:51 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

lancelotlinc wrote:
You have something against ESQL, Vitor?


No, it's more personal. Your posts are becoming less useful and more predictable. This is not your blog, and we don't have duplicate threads here.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Feb 24, 2012 12:36 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Your XPath expression looks OK to me - although you don't actually need this line:
Code:
expr4.addNamespacePrefix("set","http://icm.xxx.com/data/settings");
...because your XPath expression never refers to that namespace.

Did you notice that it was easier to read that line of code, because I wrapped it in [c o d e] tags? Please do the same, as a courtesy to the people who are reading your question.

Next steps:
- Assume that the XPath engine in WMB works correctly. It usually does a pretty good job.
- Add a Trace node just before the JCN with pattern set to {Root}
- Take a user trace

The user trace will show you the exact message tree that the XPath engine is working against. That seems like a useful piece of diagnostic info
You may even get lucky, and find something else in the user trace that leads you to understand the problem.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Feb 24, 2012 4:17 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

EAI Developer wrote:
Code:
mRequest = globalEnv.getFirstElementByPath("./PCM/Request_xml")

What is globalEnv set to? Which message tree? What does the message tree structure look like?

EAI Developer wrote:
Code:
MbXPath expr4 = new MbXPath("/soapenv:Envelope/soapenv:Body/feat:updateCurrentSettings/feat:sessionId/@com:SessionId");
expr4.addNamespacePrefix("feat","http://icm.xxx.com/soap/xxx");
expr4.addNamespacePrefix("com","http://icm.xxx.com/data/common");
expr4.addNamespacePrefix("set","http://icm.xxx.com/data/settings");
expr4.addNamespacePrefix("pres","http://icm.xxx.com/data/presence");

The namespace prefix for "soapenv" is missing; "set" and "pres" aren't used.
Back to top
View user's profile Send private message
EAI Developer
PostPosted: Mon Feb 27, 2012 2:38 pm    Post subject: Reply with quote

Centurion

Joined: 30 Nov 2005
Posts: 101
Location: US

globalEnv is set to /PCM/Request_xml, where Request_xml = <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:feat="http://icm.xxx.com/soap/xxx" xmlns:com="http://icm.xxx.com/data/common" xmlns:set="http://icm.xxx.com/data/settings" xmlns:pres="http://icm.xxx.com/data/presence"><soapenv:Header/><soapenv:Body><feat:updateCurrentSettings><feat:sessionId com:SessionId="0332116575276"/>.

I have tried this xpath, where i don't need set 'all' namespace prefixes. Issue is till there.

Code:

MbXPath expr4 = new MbXPath("//feat:sessionId/[@*]");

_________________
___________________
Regards,
EAI Developer.
Back to top
View user's profile Send private message Visit poster's website
kimbert
PostPosted: Mon Feb 27, 2012 4:09 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Please excuse the question, but...
I assume that you know that the MbXPath facility operates on the message tree, and *not* on an (unparsed) XML string? So globalEnv needs to be the root of an XMLNSC message tree, and NOT a character string.

Have you tried the steps that I suggested in my previous post? How about putting in a Trace node and then posting the tree structure.
Back to top
View user's profile Send private message
EAI Developer
PostPosted: Mon Mar 05, 2012 6:06 am    Post subject: Reply with quote

Centurion

Joined: 30 Nov 2005
Posts: 101
Location: US

Hi,
Thanks for the help. I was creating xmlnsc parser after getting the xml from the global env. Now, I have created the xmlnsc parser in the global env, before injecting xml message into global env, which resolved the issues.
_________________
___________________
Regards,
EAI Developer.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbXpath issue
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.