2011-08-08 48 views
1

我試圖運行在Ubuntu 11.04 64位的Apache Synapse示例,我發現問題樣品NR評估XPath表達式2問題的計算XPath,而使用Apache突觸

我的XPath表達式:

$ <soapenv:Body><m0:getQuote xmlns:m0="http://services.samples"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote></soapenv:Body></soapenv:Envelope> 

和R:

$ <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> 

它是以下數據運行esult是:

2011-08-08 15:37:04227 [ - ] [HttpClientWorker-1] DEBUG SwitchMediator的XPath:// M0:爲getQuote/M0:請求/ M0:符號的計算結果爲:

2011 -08-08 15:37:04227 [ - ] [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

以飽滿的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">