You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by gv_bob <gv...@yahoo.com> on 2008/01/16 15:06:49 UTC

content based router problem

Hello there,

I am unable to get a simple cbr service to work. The xpath query always
returns false. Snippets of the xbean.xml, the input message, and the error
trace are provided below. Please help! Any suggestions appreciated.


>From the xbean.xml:

<eip:content-based-router service="abc:cbr" endpoint="endpoint1">
  <eip:rules>
    <eip:routing-rule>
        <eip:predicate>
            <eip:xpath-predicate xpath="number(/items) > 0" />
        </eip:predicate>
        <eip:target>
          <eip:exchange-target...>
        <eip:target>
    <eip:routing-rule>
    <!-- no default destination>
  <eip:rules>
<eip:content-based-router>


The input message:

<?xml ... ?>
<DemoObject xmlnls="...">
  <MyDemo xmlns="...">
     ...
     <items>2</items>
     ...
  </MyDemo>
</DemoObject>

Here's the error message. I realize there's no matching rule, but my
question is, why does the xpath expression return false? I've tried this:
xpath="count(/DemoObject) = 1" which fails too. 


ERROR - EIPComponent          - Error processing InOut[
  id: ID: 7.224.72.221-1...
  status: Active
  role: provider
  service: {http://http://demo/abc}cbr
  enfpoint: endpoint1
  in: <?xml ... ?><DemoObject xmlns="...">
        <MyDemo xmlns="..."

         ...

]
java.jbi.messaging.MessagingException: No matching rule found for exchange
      at org.apache...


-- 
View this message in context: http://www.nabble.com/content-based-router-problem-tp14881328s12049p14881328.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: content based router problem

Posted by Guillaume Nodet <gn...@gmail.com>.
If you use XPath expressions to query an xml document containing namespaces,
you *do* need to configure these namespaces on your xpath expression.
    xpath="count(/ns:DemoObject) = 1"
To be able to do that, you need to configure the namespaces

  <eip:xpath-predicate xpath="count(/replaceMe:world) = 1"
namespaceContext="#nsContext"/>

  <eip:namespace-context id="nsContext">
    <eip:namespaces>
      <eip:namespace
prefix="replaceMe">http://servicemix.apache.org/replaceMe</eip:namespace>
    </eip:namespaces>
  </eip:namespace-context>


Another way is to not check the namespaces (not sure of the exact syntax):
    xpath="count(/*:DemoObject) = 1"

On Jan 16, 2008 3:06 PM, gv_bob <gv...@yahoo.com> wrote:

>
> Hello there,
>
> I am unable to get a simple cbr service to work. The xpath query always
> returns false. Snippets of the xbean.xml, the input message, and the error
> trace are provided below. Please help! Any suggestions appreciated.
>
>
> From the xbean.xml:
>
> <eip:content-based-router service="abc:cbr" endpoint="endpoint1">
>  <eip:rules>
>    <eip:routing-rule>
>        <eip:predicate>
>            <eip:xpath-predicate xpath="number(/items) > 0" />
>        </eip:predicate>
>        <eip:target>
>          <eip:exchange-target...>
>        <eip:target>
>    <eip:routing-rule>
>    <!-- no default destination>
>  <eip:rules>
> <eip:content-based-router>
>
>
> The input message:
>
> <?xml ... ?>
> <DemoObject xmlnls="...">
>  <MyDemo xmlns="...">
>     ...
>     <items>2</items>
>     ...
>  </MyDemo>
> </DemoObject>
>
> Here's the error message. I realize there's no matching rule, but my
> question is, why does the xpath expression return false? I've tried this:
> xpath="count(/DemoObject) = 1" which fails too.
>
>
> ERROR - EIPComponent          - Error processing InOut[
>  id: ID: 7.224.72.221-1...
>  status: Active
>  role: provider
>  service: {http://http://demo/abc}cbr <http://http://demo/abc%7Dcbr>
>  enfpoint: endpoint1
>  in: <?xml ... ?><DemoObject xmlns="...">
>        <MyDemo xmlns="..."
>
>         ...
>
> ]
> java.jbi.messaging.MessagingException: No matching rule found for exchange
>      at org.apache...
>
>
> --
> View this message in context:
> http://www.nabble.com/content-based-router-problem-tp14881328s12049p14881328.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/