Evaluate Response XPath assertion failed
search cancel

Evaluate Response XPath assertion failed


Article ID: 140869


Updated On:


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


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/">
      <Login xmlns="http://<hostname>.<yourdomain>.com/LoginWS">
         <LoginResult Result="OK"/>

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?


Component : API Gateway


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.


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