我试图使用BeanShell将SOAP请求打印到文件中,因为我不得不做一些验证。Jmeter中存储的SOAP调用的请求在哪里
我能够使用String response = prev.getResponseDataAsString();
获得SOAP调用的响应,这些响应可以打印到文件中。
类似的,可以用什么方法来获取在Jmeter中为SOAP调用发送的请求?
注:我试图使用SoapSampler.getxmldata()
。但它没有给我结果。
我试图使用BeanShell将SOAP请求打印到文件中,因为我不得不做一些验证。Jmeter中存储的SOAP调用的请求在哪里
我能够使用String response = prev.getResponseDataAsString();
获得SOAP调用的响应,这些响应可以打印到文件中。
类似的,可以用什么方法来获取在Jmeter中为SOAP调用发送的请求?
注:我试图使用SoapSampler.getxmldata()
。但它没有给我结果。
如果将SOAP请求作为HTTP POST调用进行提交,并将xml内容用作POST主体,则prev.getSamplerData()
将包含请求信息。
例子:
在BeanShell的后处理器:vars.put("requestData", prev.getSamplerData());
结果:
requestData=POST url
POST data:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
...
</soap:Body>
</soap:Envelope>
如果使用SOAP/XML-RPC Request你可以访问它的XML身体Beanshell PostProcessor为:
String body = ctx.getCurrentSampler().getXmlData();
哪里ctx
是的简写class
我无法使用ctx获取请求SOAP消息。 BeanShell PostProcessor中的代码存在一些问题吗? 'f = new FileOutputStream(ResultDir,true); p = new PrintStream(f); String a = ctx.getCurrentSampler()。getxmlData(); (a);' – Maniram
1.在'getXmlData();'2中注意大写“X”;我会推荐关闭像'p.close();'的流,因为让它们打开可能会导致打开句柄缺少 –
可爱..是的,它确实工作..感谢纠正.. 和是的,我已经使用p.close()和f.close()以及。 – Maniram
太棒了!这正是我在API文档中所寻找的。你能告诉我哪种类的API持有这种方法吗? – Maniram
https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html#getSamplerData() – RaGe
酷...非常感谢...我已经经历过这个类,但没有检查这个.. – Maniram