【发布时间】:2014-06-10 13:40:32
【问题描述】:
我应该将图像转换为数组字节并将其与 Web 服务 中的目标位置一起发送。 我有这段代码用 beanshell 写的
File file = new File("\\PICS\\k6.jpg");
FileInputStream in = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int i=0;
for (int i; (i = in.read(buffer)) != -1; )
{
bos.write(buffer, 0, i);
}
in.close();
byte[] imageData = bos.toByteArray();
bos.close();
vars.put("imageData", new String(imageData));
我正面临这个错误- 在文档的元素内容中发现了无效的 XML 字符 (Unicode: 0x0)。
变量“imageData”似乎是 ASCII 但如何将它与请求一起发送。我需要数组对象
【问题讨论】:
标签: web-services bytearray jmeter