You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by sandeep reddy <sa...@in2m.com> on 2008/06/16 16:50:01 UTC

Problem regarding XPath in camel

I am using Authentication and Authorization using ServiceMix Properties Login
Module. If the user is coming
from Application 1, then the message is routed to Application 2 and vice
versa.

Sample flow:
Application 1 -->  Http-BC(consumer) --> Camel-SE --> Http-BC (provider) -->
Application 2

For checking this condition I am using JXPath expression in Camel-SU. This
how it looks:
 <xpath>securitySubject/principals[*]/name='smx'</xpath>

I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.

But its not working. It is not giving any errors (even in DEBUG mode) so I
am finding it difficult to 
troubleshoot.

Please help?



-- 
View this message in context: http://www.nabble.com/Problem-regarding-XPath-in-camel-tp17866139p17866139.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem regarding XPath in camel

Posted by sandeep reddy <sa...@in2m.com>.
I have verified the logs by setting the DEBUG mode for org.apache.camel
module in log4j.xml but still there are no extra information. Also I have
already taken into consideration namespaces.

I need to implement logic in Camel to route a request to a specific service
based on which application is making a request. I can identify an
application based on principals set in security subject of the message. The
problem is that I am not able to get access to security subject in the Camel
routing. Is this something which is specific to XML configuration ?

Also can anybody suggest other better alternatives of how we can identify an
application making request to ServiceMix other than looking for security
subject of the message. 

Thanks,
Sandeep.


tmi wrote:
> 
> Also in case your incoming XML message uses namespaces you need to handle
> them in your xpath expression inside your Camel route.
> 
> E.g. consider the following example:
> 
> public void configure() {
>   Namespaces ns = new Namespaces("tns",
> "http://servicemix.apache.org/samples/wsdl-first/types");
>   ns.add("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
> 
>   from("jbi:endpoint:http://test.org/company/camel/Myendpoint").
>   choice().
>     when().xpath("//GetPerson", ns).to("jbi:service:blah").
>     otherwise().to("jbi:service:blah2").
>   end();
> }
> 

-- 
View this message in context: http://www.nabble.com/Problem-regarding-XPath-in-camel-tp17866139p18009658.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem regarding XPath in camel

Posted by James Strachan <ja...@gmail.com>.
Its a real minor nit, but the example doesn't actually use any of the
namespace prefixes you define in the Namespaces object :)

You might wanna change the example to this...

    when().xpath("//tns:GetPerson", ns).to("jbi:service:blah").


2008/6/18 tmi <mi...@web.de>:
>
> Also in case your incoming XML message uses namespaces you need to handle
> them in your xpath expression inside your Camel route.
>
> E.g. consider the following example:
>
> public void configure() {
>  Namespaces ns = new Namespaces("tns",
> "http://servicemix.apache.org/samples/wsdl-first/types");
>  ns.add("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
>
>  from("jbi:endpoint:http://test.org/company/camel/Myendpoint").
>  choice().
>    when().xpath("//GetPerson", ns).to("jbi:service:blah").
>    otherwise().to("jbi:service:blah2").
>  end();
> }
> --
> View this message in context: http://www.nabble.com/Problem-regarding-XPath-in-camel-tp17866139p17985845.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Problem regarding XPath in camel

Posted by tmi <mi...@web.de>.
Also in case your incoming XML message uses namespaces you need to handle
them in your xpath expression inside your Camel route.

E.g. consider the following example:

public void configure() {
  Namespaces ns = new Namespaces("tns",
"http://servicemix.apache.org/samples/wsdl-first/types");
  ns.add("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");

  from("jbi:endpoint:http://test.org/company/camel/Myendpoint").
  choice().
    when().xpath("//GetPerson", ns).to("jbi:service:blah").
    otherwise().to("jbi:service:blah2").
  end();
}
-- 
View this message in context: http://www.nabble.com/Problem-regarding-XPath-in-camel-tp17866139p17985845.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem regarding XPath in camel

Posted by Gert Vanthienen <ge...@skynet.be>.
Sandeep Reddy,

If you set your logging to DEBUG, does your XML message contain these 
tags/elements?  Could you post the complete Camel route you are using?  
Could you try setting DEBUG for org.apache.camel as well to get more 
information?  Are you sure this XPath expression does what you expect it 
to do?  I would expect something like 
one-or-more(securitySubject/prinicipals[name='smx'])

Gert

sandeep reddy wrote:
> I am using Authentication and Authorization using ServiceMix Properties Login
> Module. If the user is coming
> from Application 1, then the message is routed to Application 2 and vice
> versa.
>
> Sample flow:
> Application 1 -->  Http-BC(consumer) --> Camel-SE --> Http-BC (provider) -->
> Application 2
>
> For checking this condition I am using JXPath expression in Camel-SU. This
> how it looks:
>  <xpath>securitySubject/principals[*]/name='smx'</xpath>
>
> I have servicemix-camel 3.2.2 snapshot in my ServiceMix 3.2.1 instance.
>
> But its not working. It is not giving any errors (even in DEBUG mode) so I
> am finding it difficult to 
> troubleshoot.
>
> Please help?
>
>
>
>