2014-02-08 88 views

回答

0

您可以使用filter mediator執行基於內容的中介。以下示例顯示了您的用例。 (1)使用xpath匹配完成過濾。它搜索不發生XPath // p:echoString/test,並基於此執行豐富中介。以下肥皂身體將匹配過濾器。 (2)

(1)

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" name="messageFilter" transports="http https" startOnLoad="true" trace="disable"> 
    <target> 
     <inSequence> 
      <log level="full" separator=","/> 
      <filter xpath="not(//p:echoString/test)" xmlns:p="http://echo.services.core.carbon.wso2.org" > 
       <then> 
        <log separator=","> 
         <property name="XPath Matched" value="true"/> 
        </log> 
        <enrich> 
         <source clone="true" xpath="//p:echoString/in"/> 
         <target type="property" property="ORIGINAL_REQ"/> 
        </enrich> 
        <log separator=","> 
         <property name="ORIGINAL_REQ" expression="get-property('ORIGINAL_REQ')"/> 
        </log> 
       </then> 
       <else> 
        <log separator=","> 
         <property name="XPath Matched" value="false"/> 
        </log> 
       </else> 
      </filter> 
      <send> 
       <endpoint> 
        <address uri="http://localhost:9763/services/echo"/> 
       </endpoint> 
      </send> 
     </inSequence> 
     <outSequence> 
      <log level="full" separator=","> 
       <property name="OUT-SEQUENCE" value="property_value"/> 
      </log> 
      <send/> 
     </outSequence> 
     <faultSequence/> 
    </target> 
</proxy> 

(2)

<body> 
    <p:echoString xmlns:p="http://echo.services.core.carbon.wso2.org"> 
     <in>123</in> 
     <test>testing-node</test> 
    </p:echoString> 
</body> 
相關問題