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://example.ca.com/LoginWS">
         <LoginResult Result="OK"/>
         <Key>8C54D76F478739FFBFE14EDB831F3675</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?

Cause

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

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

Environment

Component : API Gateway

Resolution

The SOAP Response message contains an XML namespace in the <Login> tag (xmlns="http://example.ca.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'.