【问题标题】:Problem with evaluating XPath while using Apache Synapse使用 Apache Synapse 时评估 XPath 的问题
【发布时间】:2011-10-22 10:04:51
【问题描述】:

我正在尝试在 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,所以有可能那个系统上缺少一些东西。

【问题讨论】:

    标签: xpath ubuntu synapse


    【解决方案1】:

    尝试使用完整的 xpath..

     

    【讨论】:

      猜你喜欢
      • 2013-07-13
      • 2013-11-04
      • 1970-01-01
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      相关资源
      最近更新 更多