【问题标题】:WSO2 ESB how to read XML attribute response from the EndpointWSO2 ESB 如何从端点读取 XML 属性响应
【发布时间】:2019-04-23 14:53:03
【问题描述】:

我创建了一个 API 女巫调用和端点并返回一些响应。根据 Endpoint 返回的响应,我想检索 status 值并继续下一步。

这是我的api.xml 的样子。

<api context="/sendSms" name="SendSmsApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/{username}/{password}">
    <inSequence>
        <property expression="get-property('MessageID')" name="msgID" scope="default" type="STRING"/>
        <log level="custom">
            <property expression="$trp:requestId" name="Request ID"/>
            <property expression="get-property('msgID')" name="msgID"/>
        </log>
        <call>
            <endpoint key="SmsLoginEP"/>
        </call>
        <property expression="what should i put here ?" name="response" scope="default" type="STRING"/>
        <log level="custom">
            <property expression="get-property('response')" name="Response"/>
        </log>
        <respond/>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence/>
</resource>

这是我从端点获得的 XML

<rsp status="fail"><err returncode="-2" desc="username record not found."</err></rsp>

我的问题是我如何获取属性status 是失败还是通过并将其插入到属性调解器中,以便之后我可以执行切换调解器。

【问题讨论】:

    标签: xpath wso2 wso2esb synapse


    【解决方案1】:

    您从端点获得的 XML 格式不正确,标签 err 未正确打开。如果假设它看起来像:

    &lt;rsp status="fail"&gt;&lt;err returncode="-2" desc="username record not found."&gt;&lt;/err&gt;&lt;/rsp&gt;

    然后你可以使用:/rsp/@status 它将以字符串形式返回fail

    在此处查看Demo

    【讨论】:

      猜你喜欢
      • 2017-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多