Unable to extract variables from a SOAP response through Extract Variables

We have the below soap xml response-

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <bookUnBookSimNumberResponse xmlns="http://webservice.bmc.pharmacy.com">
         <bookUnBookSimNumberReturn>
            <activationCode xsi:nil="true"/>
            <errorCode>ABC</errorCode>
            <errorMessage>Not Enough COVID-19 vaccine Available</errorMessage>
            <errorType>FUNCTIONAL</errorType>
            <imsi xsi:nil="true"/>
            <packedProduct xsi:nil="true"/>
            <puk2 xsi:nil="true"/>
            <simCategory xsi:nil="true"/>
            <simNumber xsi:nil="true"/>
            <simStatus xsi:nil="true"/>
            <status>ERROR</status>
            <storeId xsi:nil="true"/>
         </bookUnBookSimNumberReturn>
      </bookUnBookSimNumberResponse>
   </soapenv:Body>
</soapenv:Envelope>
<br />

We used the below extraction but unfortunately the values aren't assigned to the variables.

<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-GetBookUnBookSimNumberResponse">
   <DisplayName>EV-GetBookUnBookSimNumberResponse</DisplayName>
   <Properties/>
   <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
   <Source clearPayload="false">response</Source>
   <XMLPayload stopPayloadProcessing="false">
      <Namespaces>
         <Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
        
      </Namespaces>
      <Variable name="activationCode" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/activationCode</XPath>
      </Variable>
      <Variable name="errorCode" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/errorCode</XPath>
      </Variable>
      <Variable name="errorMessage" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/errorMessage</XPath>
      </Variable>
      <Variable name="errorType" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/errorType</XPath>
      </Variable>
      <Variable name="imsi" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/imsi</XPath>
      </Variable>
      <Variable name="packedProduct" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/packedProduct</XPath>
      </Variable>
      <Variable name="puk2" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/puk2</XPath>
      </Variable>
      <Variable name="simCategory" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/simCategory</XPath>
      </Variable>
      <Variable name="simNumber" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/simNumber</XPath>
      </Variable>
      <Variable name="simStatus" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/simStatus</XPath>
      </Variable>
      <Variable name="status" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/status</XPath>
      </Variable>
      <Variable name="storeId" type="string">
         <XPath>/soapenv:Envelope/soapenv:Body/bookUnBookSimNumberResponse/bookUnBookSimNumberReturn/storeId</XPath>
      </Variable>
   </XMLPayload>
</ExtractVariables>
<br />

Kindly suggest.

0 2 374
2 REPLIES 2

The problem is that the bookUnBookSimNumberResponse element in the response is bound to a namespace but doesn't declare an alias.

This example XPath expression will extract errorCode

/soapenv:Envelope/soapenv:Body/*[local-name()='bookUnBookSimNumberResponse']/*[local-name()='bookUnBookSimNumberReturn']/*[local-name()='errorCode']

the xpath that you wrote will not catch anything because of ns inside the block.

Try this:

//*[local-name()='errorCode']

as example for getting errorCode element:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
    <DisplayName>Extract Variables-1</DisplayName>
    <Properties/>
    <Source clearPayload="false">response</Source>
    <VariablePrefix>apigeexpath</VariablePrefix>
    <XMLPayload stopPayloadProcessing="false">
        <Namespaces>
            <Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
        </Namespaces>
        <Variable name="name" type="string">
            <XPath>//*[local-name()='errorCode']</XPath>
        </Variable>
    </XMLPayload>
</ExtractVariables>