【问题标题】:WSO2 : Determining that a message contains a specific element or notWSO2:确定消息是否包含特定元素
【发布时间】:2014-02-09 07:31:16
【问题描述】:

如何确定消息包含特定元素?如果消息不包含特定元素,我想丰富消息,但我不知道如何确定?

谢谢。

【问题讨论】:

    标签: soap wso2 esb


    【解决方案1】:

    您可以使用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>
    

    【讨论】:

      猜你喜欢
      • 2017-08-01
      • 2013-07-31
      • 1970-01-01
      • 1970-01-01
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 2023-01-02
      • 1970-01-01
      相关资源
      最近更新 更多