我正在尝试在ubuntu 11.04 64位上运行Apache Synapse示例,我发现在示例nr 2中评估XPath表达式时遇到了问题。
我的XPath表达式:
$ <definitions xmlns="http://ws.apache.org/ns/synapse"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd">
<sequence name="main">
<switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples">
<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
<case regex="MSFT">
<property name="symbol" value="Are you sure? - MSFT"/>
</case>
<default>
<!-- it is possible to assign the result of an XPath expression as well -->
<property name="symbol" expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"/>
</default>
</switch>
<log level="custom">
<!-- the get-property() XPath extension function allows the lookup of local message properties
as well as properties from the Axis2 or Transport contexts (i.e. transport headers) -->
<property name="symbol" expression="get-property('symbol')"/>
<!-- the get-property() function supports the implicit message headers To/From/Action/FaultTo/ReplyTo -->
<property name="epr" expression="get-property('To')"/>
</log>
<!-- Send the messages where they are destined to (i.e. the 'To' EPR of the message) -->
<send/>
</sequence>
运行以下数据:
$ <soapenv:Body><m0:getQuote xmlns:m0="http://services.samples"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote></soapenv:Body></soapenv:Envelope>
结果是:
2011-08-08 15:37:04,227 [ - ] [HttpClientWorker-1] DEBUG SwitchMediator XPath:// m0:getQuote / m0:request / m0:symbol的计算结果为:
2011-08-08 15:37:04,227 [ - ] [HttpClientWorker-1] DEBUG SwitchMediator没有匹配的开关案例 - 执行默认
虽然应该去:
$<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
有谁知道会出现什么问题?我几天前安装了ubuntu,因此有可能在该系统上缺少某些内容。
答案 0 :(得分:0)
尝试使用完整的xpath ..
<switch xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:m0="http://services.samples" source="//soapenv:Envelope/soapenv:Body/m0:getQuote/m0:request/m0:symbol">