Quantcast

fail filter XPATH (camel)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

fail filter XPATH (camel)

ABouchama
Hello,

I'm trying to developp camel route to filter messages XML format (xpath)

This is my configuration:

<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
     <from uri="activemq:XML"/>
        <choice>
                <when>
                        <xpath>/Envelope/Header[Action='Customer']</xpath>
                  <to uri="activemq:queue:CUSTOMER"/>
                </when>
                <otherwise>
                    <to uri="activemq:queue:CONTACT"/>
                </otherwise>
            </choice>
</route>
</camelContext>


This configuration work very fine for message in this xml format :
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Header>
<Action>Customer</Action>
</Header>

But in this XML format, does not work:

xml version = "1.0" encoding = "UTF-8"?
<Envelope Xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message"> 
<Header> 
<Action> Customer </ Action> 
</ Header> 


There's someone who could help me solve this problem,

thank you in advance

version activemq : fuse message broker 5.3.0.3
version java       :  Java 1.6

Best regards,

titexe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: fail filter XPATH (camel)

Maciek Próchniak
Hi,
guess you need to make your xpath namespace aware.
you can find example here: http://camel.apache.org/xpath.html,
in part named 'Using XML configuration'
In your case I guess it would look sth like:

<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
xmlns:ns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message"
<route>
     <from uri="activemq:XML"/>
        <choice>
                <when>
                        <xpath>/ns:Envelope/ns:Header[ns:Action='Customer']</xpath>
                  <to uri="activemq:queue:CUSTOMER"/>
                </when>
                <otherwise>
                    <to uri="activemq:queue:CONTACT"/>
                </otherwise>
            </choice>
</route>
</camelContext>

- but I didn't check it - so it may be a bit different ;)

br,
maciek

On Wed, 2009-09-23 at 09:27 -0700, titexe wrote:

> Hello,
>
> I'm trying to developp camel route to filter messages XML format (xpath)
>
> This is my configuration:
>
> <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
> <route>
>      <from uri="activemq:XML"/>
> <choice>
>                 <when>
> <xpath>/Envelope/Header[Action='Customer']</xpath>
>                   <to uri="activemq:queue:CUSTOMER"/>
>                 </when>
>                 <otherwise>
>                     <to uri="activemq:queue:CONTACT"/>
>                 </otherwise>
>             </choice>
> </route>
> </camelContext>
>
> This configuration work very fine for message in this xml format :
> <?xml version="1.0" encoding="UTF-8"?>
> <Envelope>
> <Header>
> <Action>Customer</Action>
> </Header>
>
> But in this XML format, does not work:
>
> xml version = "1.0" encoding = "UTF-8"?
> <Envelope
> Xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message">
> <Header>
> <Action> Customer </ Action>
> </ Header>
>
>
> There's someone who could help me solve this problem,
>
> thank you in advance
>
> version activemq : fuse message broker 5.3.0.3
> version java       :  Java 1.6
>
> Best regards,
>
> titexe
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: fail filter XPATH (camel)

ABouchama
In reply to this post by ABouchama
Problem fixed : the declaration of namespace must be in camel context not in bean.

Thank you for your reactivity
titexe wrote
Hello,

I'm trying to developp camel route to filter messages XML format (xpath)

This is my configuration:

<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
     <from uri="activemq:XML"/>
        <choice>
                <when>
                        <xpath>/Envelope/Header[Action='Customer']</xpath>
                  <to uri="activemq:queue:CUSTOMER"/>
                </when>
                <otherwise>
                    <to uri="activemq:queue:CONTACT"/>
                </otherwise>
            </choice>
</route>
</camelContext>


This configuration work very fine for message in this xml format :
<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Header>
<Action>Customer</Action>
</Header>

But in this XML format, does not work:

xml version = "1.0" encoding = "UTF-8"?
<Envelope Xmlns="http://schemas.microsoft.com/dynamics/2006/02/documents/Message"> 
<Header> 
<Action> Customer </ Action> 
</ Header> 


There's someone who could help me solve this problem,

thank you in advance

version activemq : fuse message broker 5.3.0.3
version java       :  Java 1.6

Best regards,

titexe
Loading...