Yasothar
Yasothar

Reputation: 453

WSO2 ESB - Xpath expression returns null value on SOAP response

I have a basic sequence that calls an endpoint and update the response in the database via a data service. I have done the needful and when calling the endpoint I'm getting the following response which is the expected one (This response is getting printed in the log file).

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1">
            <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-19033">
                <wsu:Created>2016-04-26T04:35:21.802Z</wsu:Created>
                <wsu:Expires>2016-04-26T04:40:21.802Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <ns2:purchaceFromMMRResponse xmlns:ns2="http://flw.mwt.mobitel.com/">
            <return>
                <amount>1.0</amount>
                <date>26042016</date>
                <mobile>0711325362</mobile>
                <recipetNo>20160426100525249665</recipetNo>
                <resultCode>1999</resultCode>
                <resultDesc>Dear Customer,Service is not available due to a technical failure. Please try again in a while .</resultDesc>
                <time>100449</time>
                <transactionId>SDC311521</transactionId>
            </return>
        </ns2:purchaceFromMMRResponse>
    </soapenv:Body>
</soapenv:Envelope>

To call the data service (and update the response fields) I need to get the response values from soap response.For this I used an xpath expression to get the value which will be set in a property and then used in the data service.

<property expression="//ns2:return/ns2:mobile/text()"
        name="mobile" scope="default" type="STRING" xmlns:ns2="http://flw.mwt.mobitel.com/"/>

After setting the value to the property when I do a custom log

<log level="custom">
        <property expression="$ctx:mobile" name="mobile"/>
</log>  

the value is not getting printed. Please correct me If I'm doing anything wrong here.

Upvotes: 0

Views: 720

Answers (1)

Jean-Michel
Jean-Michel

Reputation: 5946

The nodes return and mobile does not belong to ns2 namespace, try with //return/mobile/text()

Upvotes: 1

Related Questions