Evaluate Response XPath assertion failed
search cancel

Evaluate Response XPath assertion failed

book

Article ID: 140869

calendar_today

Updated On:

Products

CA API Gateway API SECURITY CA API Gateway Precision API Monitoring Module for API Gateway (Layer 7) CA API Gateway Enterprise Service Manager (Layer 7) STARTER PACK-7 CA Microgateway

Issue/Introduction

The value of the "Key" element needs to be extracted from the following SOAP Response message.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <Login xmlns="http://<hostname>.<yourdomain>.com/LoginWS">
         <LoginResult Result="OK"/>
         <Key><key_value></Key>
      </Login>
   </soap:Body>
</soap:Envelope>

The XPath "/s:Envelope/s:Body/Login/Key" was specified for the "Evaluate Response XPath" assertion, but it was failed with the following Associated Logs message.

XPath pattern didn't match response or target message; assertion therefore fails; XPath is '/s:Envelope/s:Body/Login/Key'.

What's wrong?

Environment

Component : API Gateway

Cause

A prefix wasn't defined for the XML element "Login" which has an xmlns attribute (xmlns="http://<hostname>.<yourdomain>.com/LoginWS").

A prefix has to be defined and it must be specified in the XPath.

Resolution

The SOAP Response message contains an XML namespace in the <Login> tag (xmlns="http://<hostname>.<yourdomain>.com/LoginWS"), so a prefix for the namespace has to be defined same as the 's' prefix for the SOAP namespace.

For example, the XPath has to be defined as '/s:Envelope/s:Body/k:Login/k:Key' if the prefix is defined as 'k'.