how to use xpath in camel-context.xml to check if a particular node is exist or not -


i trying develop content-based routing camel application. application @ folder src/data see if there soap request file has node <e2d:getorderdetairequest>, file copy target/message, otherwise file copy target/other.

do know how use xpath(or other tools ) check condition (i prefer using camel-context.xml file)?

here camel-context

<route>         <from uri="file://c:/src/data?noop=true"/>         <choice>            <when>             <xpath>**???????????????????????????**</xpath>                 <to uri="file://c:/target/message"/>            </when>            <otherwise>             <to uri="file://c:/target/other"/>            </otherwise>         </choice>     </route> 

and here sample of 2 different soap requests

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:e2d="http://www.abc.com/abc11ws">    <soapenv:header/>    <soapenv:body>       <e2d:getorderdetailrequest>          <actioncode>1234</actioncode>       </..>    </...></...> 

and

<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:lsr="http://www.abc.com/abc22ws">    <soapenv:header/>    <soapenv:body>       <lsr:getproductdetailsrequest>            <productid>12345</...>      </...></...></...> 

when using xpath , xml has namespaces, such soap message, must use namespaces in xpath expression well.

there details @ camel docmentation at: http://camel.apache.org/xpath

by using xml dsl in camel can declare namespace in xml tag directly such in camelcontext etc.

<camelcontext xmlns="http://camel.apache.org/schema/spring" e2d="http://www.abc.com/abc11ws">    ...    <when>      <xpath>/e2d:getorderdetailrequest</xpath>        ... 

but mind xpaths can bit tricky working correctly. , why added lognamespaces in camel 2.10. see details in bottom of page: http://camel.apache.org/xpath


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -