2014-02-08 56 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> 
相关问题