1

I have create one API witch call and Endpoint and return some response. Base on the response the Endpoint return, I want to retrieve the status value and proceed to the next step.

This is my api.xml looks like.

<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>

and this is the XML that I get from the endpoint

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

My question is how do i get the attribute status whether its fail or pass and insert it into property mediator so that i can perform switch mediator after that.

Community
  • 1
  • 1
ameruddin jamil
  • 155
  • 4
  • 18

1 Answers1

3

The XML you got from endpoint is not well form tag err is not properly open. If suppose it is look like:

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

Then you can use: /rsp/@status it will return fail as string

See Demo here.

Amrendra Kumar
  • 1,806
  • 1
  • 7
  • 17