Dav*_*vid 4 xpath xmlnode apache-camel
我正在尝试开发基于内容的路由骆驼应用程序.此应用程序将查看文件夹src/data以查看是否存在具有节点的SOAP请求文件<e2d:getOrderDetaiRequest>,然后该文件将被复制到目标/消息中,否则该文件将被复制到目标/其他.
你知道如何使用xpath(或任何其他工具)来检查这个条件(我更喜欢使用camel-context.xml文件)?
这是我的骆驼语境
<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>
Run Code Online (Sandbox Code Playgroud)
这是2个不同SOAP请求的示例
<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>
</..>
</...></...>
Run Code Online (Sandbox Code Playgroud)
和
<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</...>
</...></...></...>
Run Code Online (Sandbox Code Playgroud)
使用xpath并且xml具有名称空间(例如SOAP消息)时,您还必须在xpath表达式中使用名称空间.
Camel docmentation有一些细节:http://camel.apache.org/xpath
通过在Camel中使用XML DSL,您可以直接在XML标记中声明命名空间,例如在camelContext等中.
<camelContext xmlns="http://camel.apache.org/schema/spring" e2d="http://www.abc.com/Abc11WS">
...
<when>
<xpath>/e2d:getOrderDetailRequest</xpath>
...
Run Code Online (Sandbox Code Playgroud)
但请注意,XPath可能有点棘手,无法正常工作.这就是我们在Camel 2.10中添加logNamespaces的原因.请参阅本页底部的详细信息:http://camel.apache.org/xpath
| 归档时间: |
|
| 查看次数: |
7650 次 |
| 最近记录: |