简体   繁体   English

JMeter 根据先前的响应创建 HTTP 请求正文

[英]JMeter create HTTP request body based on a previous response

I have an application that I am testing with JMeter.我有一个正在使用 JMeter 进行测试的应用程序。 One of the tests calls for a REST request to be made, parse out a field from the response, and use that value as part of a new REST request.其中一项测试要求发出 REST 请求,从响应中解析出一个字段,并将该值用作新 REST 请求的一部分。 The complication is that in the second request, the XML payload needs a signature to be generated.复杂之处在于,在第二个请求中,XML 负载需要生成签名。

What I'd like to know is, is there a way to execute custom Java code in JMeter and have the resulting XML fill in the POST body of a JMeter HTTP request?我想知道的是,有没有办法在 JMeter 中执行自定义 Java 代码并将生成的 XML 填充到 JMeter HTTP 请求的 POST 正文中?

You can use beanshell sampler or beanshell preprocessor sampler to call java code in jmeter.您可以使用beanshell 采样器或 beanshell 预处理器采样器在 jmeter 中调用 java 代码。

Here you can implement signature generation using java(or add library jar to jmeter runtime) and assign the generated value to a reference variable and place the reference variable in Request Body.这里可以使用java实现签名生成(或者在jmeter运行时添加库jar),并将生成的值赋给一个引用变量,并将引用变量放到Request Body中。 Check this Q&A for more information.查看此问答以获取更多信息。 You can find a excellent overview in Blazemeter Blog您可以在Blazemeter 博客中找到出色的概述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过获取jmeter中先前的http请求的响应来更新文本文件的字段 - how to update fields of text file , by taking response of previous http request in jmeter 编码的Http请求/响应正文 - Encoded Http Request/Response body 为什么阅读 HTTP 请求的响应正文很重要? - Why is it important to read the response body of an HTTP request? Java HTTP 请求读取响应体 - Java HTTP request read response body Java中基于http请求的动态http响应 - dynamic http response based on http request in java Jmeter:如果在响应Cookie中找不到特殊字符串,则调用HTTP采样器请求 - Jmeter: Recall HTTP sampler request if a particalar string is not found in response cookie 在 Jmeter 中,如何等待前一个采样器(JDBC 请求)完成,然后启动新的采样器请求(Http 请求) - In Jmeter , how to wait for a previous sampler(JDBC Request) to finish and then start the new sampler Request(Http request) JMeter POST 响应主体为 null - JMeter POST response body is null HTTP 请求总是在响应正文中添加错误和警告 - HTTP request always add error and warning in response body Java过滤器 - 根据请求有条件地更改响应主体 - Java filter - conditionally change response body based on request
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM