soap - Jmeter 中的 Gzipped 肥皂请求
问题描述
是否可以发送 gzipped 肥皂请求?
我添加了一个带有以下标头的 HTTP 标头管理器:
Content-Type: application/soap+xml; charset=Utf-8
Content-Encoding: gzip
我添加了一个 Beanshell PreProcessor 作为需要编码的请求的子项,并定义了以下脚本:
import org.apache.commons.io.IOUtils;
import java.util.zip.GZIPOutputStream;
// This only works for the HTTP Request, not Soap Request.
// String bodyString = sampler.getArguments().getArgument(0).getValue();
String bodyString = ctx.getCurrentSampler().getXmlData();
byte [] requestBody = bodyString.getBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream(requestBody.length);
GZIPOutputStream gzip = new GZIPOutputStream(out);
gzip.write(requestBody);
gzip.close();
// This only works for the HTTP Request, not Soap Request.
// sampler.getArguments().getArgument(0).setValue(out.toString(0));
ctx.getCurrentSampler().setXmlData(???);
我的问题是最后一行,我该如何设置 xmlData?
Jmeter 3.1版
解决方案
- 将已弃用的 SOAP/XML-RPC 采样器替换为HTTP 请求采样器
- 升级到JMeter 5.0 (或JMeter 下载页面提供的最新版本)
- 从Beanshell 切换到 Groovy
- 用于
sampler.getArguments().getArgument(0).setValue(out.toString(0));
生成请求正文。
推荐阅读
- r - 尝试使用 rnorm 函数模拟数据集时遇到语法错误
- android - 视图绑定无权访问片段
- linux - 我在使用 bochs+gdb 调试 linux-0.11 时遇到了一些问题
- bash - Terraform GCP 实例元数据启动脚本问题
- python-3.x - 无法在 leetcode 每周竞赛 243 中提出的“使用服务器处理任务”问题中找到边缘案例
- python - 错误:“NoneType”和“int”的实例之间不支持“>”
- amazon-web-services - 为什么我的 AWS S3 对象计数不同
- python-3.x - 有没有办法使用python从文本文件中只提取特定的行
- reactjs - tfjs-react-native 用于实时对象检测(expo 托管工作流)
- sql-server-2012 - 将默认值设置为日期时间列中的当前日期时间,插入时不应接受除当前日期时间之外的其他日期时间