xpathsoapuioracle-soa

Extract account ID from Oracle SOA response in SoapUI


We have an Oracle SOA gateway setup that we can pass SOAP requests to. Right now, I'm trying to use SoapUI to create test cases. In this particular one, I'm trying to create a customer account. I've got the skeleton setup, but I'm having issues setting the correct XPath up to extract the account ID from the SOAP response.

The response I get back from the SOA gateway is:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header/>
   <env:Body>
      <OutputParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.oracle.com/apps/hz/soaprovider/plsql/hz_cust_account_v2pub/create_cust_account__1/">
         <X_CUST_ACCOUNT_ID>1459660</X_CUST_ACCOUNT_ID>
         <X_ACCOUNT_NUMBER>58946</X_ACCOUNT_NUMBER>
         <X_PARTY_ID>3101110</X_PARTY_ID>
         <X_PARTY_NUMBER>215767</X_PARTY_NUMBER>
         <X_PROFILE_ID>3322847</X_PROFILE_ID>
         <X_RETURN_STATUS>S</X_RETURN_STATUS>
         <X_MSG_COUNT>0</X_MSG_COUNT>
         <X_MSG_DATA xsi:nil="true"/>
      </OutputParameters>
   </env:Body>
</env:Envelope>

From this, I'm trying to extract the returned X_CUST_ACCOUNT_ID, and put it into a property. The XPath that I'm using is

//OutputParameters/X_CUST_ACCOUNT_ID 

However, doing so, all I get is an error stating

"Missing match for Source XPath [//OutputParameters/X_CUST_ACCOUNT_ID]"

I've spent hours trying various XPath expressions, and all I get are either missing match or syntax errors.


Solution

  • You were missing the fact that OutputParameters also has a default namespace defined by

    xmlns="http://xmlns.oracle.com/apps/hz/soaprovider/plsql/hz_cust_account_v2pub/create_cust_account__1/"
    

    To also ignore this namespace, you can use the following expression:

    //*[local-name()='OutputParameters']/*[local-name()='X_CUST_ACCOUNT_ID']