WSO2 ESB 4.9 - 从SOAP响应中提取值

时间:2017-03-27 10:03:02

标签: xml xpath wso2 wso2esb wso2-am

以下是我定义的输出序列。

<?xml version="1.0" encoding="UTF-8"?>
<outSequence xmlns="http://ws.apache.org/ns/synapse">
    <log category="DEBUG" level="full"/>
    <payloadFactory media-type="json">
        <format>{ "chassisNo": "$1"}</format>
        <args>
            <arg evaluator="xml"
                expression="//ns:getVehicleRegInfoResponse/ns:return/ns:chassisNo" xmlns:ns="http://schemas.abc.com/xsd/erl/dmt/v1"/>
        </args>
    </payloadFactory>
    <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
    <send/>
</outSequence>

以下是SOAP XML响应

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getVehicleRegInfoResponse xmlns="http://schemas.abc.com/xsd/erl/dmt/v1">
         <return>
            <chassisNo>MD2A17CZ6EWH43266</chassisNo>
            <engineNo>JEZWEH57019</engineNo>
            <firstRegDate>2015-01-16T00:00:00</firstRegDate>
         </return>
      </getVehicleRegInfoResponse>
   </soap:Body>
</soap:Envelope>

为什么它不起作用?

我只是想知道XPATH是否正确?

//ns:getVehicleRegInfoResponse/ns:return/ns:chassisNo

1 个答案:

答案 0 :(得分:1)

这将返回chassisNo元素。

尝试//ns:getVehicleRegInfoResponse/ns:return/ns:chassisNo/text()获取文字。