Jace
Jace

Reputation: 11

JMeter Xpath extrator

I am currently sending SOAP XML requests and receiving a response from a third party API. I am looking to retrieve a particular value that is returned in the response and pass this to a subsequent request that goes back to the same API.

I am using the XPath extractor to achieve this however when I am trying to pass the response variable on, which is returned as

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-
open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
.....
</soap:Header>
<soap:Body>
<c:replyMessage xmlns:c="---------------------------">
<c:referenceNumber>84c74155-e260-46f9-98bf-5ba6ee6cbb20</c:referenceNumber>
<c:backgroundCode>5048657036666628204009</c:backgroundCode>
.....
</c:replyMessage>
</soap:Body>
</soap:Envelope>

The fields I am attempting to pass are referenceNumber and backgroundCode using the XPath extractor response/c:referenceNumber however I receive the error

Assertion error: false
Assertion failure: true
Assertion failure message: Prefix must resolve to a namespace: c
See log file for further details.

Any advise would be greatly appreciated. If you need any more info please let me know.

Upvotes: 1

Views: 407

Answers (1)

klingac
klingac

Reputation: 463

First of all: I strongly recommend you NOT TO USE XPath extractor. It is usually difficult to use and its performance is very bad. See this article or this article

Your choices for this task:

  1. SmartMeter's Boundary Body extractor - very easy for use, and it is also very fast and has best performance of all.Example how to use it here Boundary Body extractor configuration
  2. Regular expression extractor - slower than first one, but still better than XPath extractor. Use it e.g with this regex: \<c:referenceNumber\>(.*)\<\/c:referenceNumber\> enter image description here
  3. If I did not convince you, use XPath extractor. But I warned you. Use this expression //soap:Envelope/soap:Body/*[local-name()='replyMessage']/*[local-name()='referenceNumber']. Do not forget to check Use Namespaces enter image description here

Upvotes: 1

Related Questions