首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JMeter Xpath提取器

JMeter Xpath提取器
EN

Stack Overflow用户
提问于 2017-09-08 18:25:15
回答 1查看 265关注 0票数 1

我目前正在发送SOAP XML请求并接收来自第三方API的响应。我希望检索在响应中返回的特定值,并将其传递给返回相同API的后续请求。

但是,当我尝试传递response变量时,我使用XPath提取器来实现这一点,该变量返回为

代码语言:javascript
复制
<?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>

我尝试传递的字段是使用XPath提取器响应/c: referenceNumber的referenceNumber和backgroundCode,但是我收到了错误

代码语言:javascript
复制
Assertion error: false
Assertion failure: true
Assertion failure message: Prefix must resolve to a namespace: c
See log file for further details.

任何建议都将不胜感激。如果你需要更多的信息,请让我知道。

EN

回答 1

Stack Overflow用户

发布于 2017-09-08 20:15:09

首先:我强烈建议你不要使用XPath extractor。它通常很难使用,性能也很差。请参阅this articlethis article

您对此任务的选择:

  1. SmartMeter's Boundary Body extractor -非常容易使用,而且速度非常快,性能最好的all.Example how to use how

  1. Regular expression extractor -比第一个慢,但仍然比XPath提取器好。例如,与此正则表达式一起使用:\<c:referenceNumber\>(.*)\<\/c:referenceNumber\>

  1. ,如果我没有说服你,就用XPath extractor。但是I warned you。使用此表达式//soap:Envelope/soap:Body/*[local-name()='replyMessage']/*[local-name()='referenceNumber']。不要忘记选中Use Namespaces

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46114318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档