Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 带附件的JMeter SOAP请求_File_Soap_Jmeter_Attachment - Fatal编程技术网

File 带附件的JMeter SOAP请求

File 带附件的JMeter SOAP请求,file,soap,jmeter,attachment,File,Soap,Jmeter,Attachment,我正在使用JMeter测试web服务SOAP,我正在测试的方法采用file类型的参数。在soapui中,这可以通过上传附件并为其提供ID来完成 在soap请求中,将放置如下内容: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://zk.payment.dkv.be/ws"> <soapenv:Header/> <

我正在使用JMeter测试web服务SOAP,我正在测试的方法采用file类型的参数。在soapui中,这可以通过上传附件并为其提供ID来完成

在soap请求中,将放置如下内容:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:ws="http://zk.payment.dkv.be/ws">
  <soapenv:Header/>
    <soapenv:Body>
      <ws:wsMethod>
          <file>cid:attachementID</file>
      </ws:wsMethod>
    </soapenv:Body>
</soapenv:Envelope>
我使用的是JMeter2.9,这似乎是不可能的,有人有解决办法吗


干杯

因此,在编写本文时,JMeter没有解决上述问题的方法。不是直接发送附件,而是有一个解决方法

因为在最后,这都是关于标签之间的内容:

<file>"what is here??"</file>
在上面,为了这篇文章,我忽略了导入,但不太明显的是:

import java.util.Scanner;
import org.apache.commons.codec.binary.Base64;

它们应该已经包含在jmeter的库中。就这样

因此,在编写本文时,JMeter没有解决上述问题的方法。不是直接发送附件,而是有一个解决方法

因为在最后,这都是关于标签之间的内容:

<file>"what is here??"</file>
在上面,为了这篇文章,我忽略了导入,但不太明显的是:

import java.util.Scanner;
import org.apache.commons.codec.binary.Base64;

它们应该已经包含在jmeter的库中。就这样

我使用了Fico提到的类似解决方案,请尝试下面的代码

File file = new File("C:\\103861\\A1940599.zip");
InputStream is = new FileInputStream(file);
long length = file.length();
if (length > Integer.MAX_VALUE) {
     // File is too large
}
byte[] bytes = new byte[(int)length];
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset))    >= 0) {
   offset += numRead;
}
if (offset < bytes.length) {
   throw new IOException("Could not completely read file "+file.getName());
}
is.close();
String Attachment=Base64.encodeBase64String(bytes);
vars.put("SoapAttachment",Attachment);
将XML中的SoapAttachment与${SoapAttachment}一起使用


注意-在我进行校验和计算时,您可能需要删除一些导入,因此我需要它们。

我使用了Fico提到的类似解决方案,请尝试下面的代码

File file = new File("C:\\103861\\A1940599.zip");
InputStream is = new FileInputStream(file);
long length = file.length();
if (length > Integer.MAX_VALUE) {
     // File is too large
}
byte[] bytes = new byte[(int)length];
int offset = 0;
int numRead = 0;
while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset))    >= 0) {
   offset += numRead;
}
if (offset < bytes.length) {
   throw new IOException("Could not completely read file "+file.getName());
}
is.close();
String Attachment=Base64.encodeBase64String(bytes);
vars.put("SoapAttachment",Attachment);
将XML中的SoapAttachment与${SoapAttachment}一起使用


注意-在我进行校验和计算时,您可能需要删除一些导入,因此我需要它们。

我建议创建启用附件处理的自定义Soap采样器。 目标文件夹中的解决方案源、内置JAR位于github下:

请查看我们的测试博客:

在Java 1.7下编译的最新构建jar位于:


如果您从以下站点安装Plugin Manager,您也可以下载此采样器:

我建议创建启用附件处理的自定义Soap采样器。 目标文件夹中的解决方案源、内置JAR位于github下:

请查看我们的测试博客:

在Java 1.7下编译的最新构建jar位于:


如果您从以下站点安装Plugin Manager,您也可以下载此采样器:

导入到哪里?导入到哪里?虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-我包括了你期望的链接。你可以投票给我吗?github中提供的jar是针对Java8编译的,所以一定要用Java8运行JMeter。使用JMeter 2.9和soap 1.1消息进行测试。虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-我包括了你期望的链接。你可以投票给我吗?github中提供的jar是针对Java8编译的,所以一定要用Java8运行JMeter。使用JMeter 2.9和soap 1.1消息进行测试。