[英]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.