在SoapUI中保存响应中的附件

时间:2018-08-01 21:00:52

标签: soap groovy soapui

我收到2个文件,以响应SOAP请求。我尝试使用followig Groovy脚本保存这些文件。我将脚本用作测试步骤的脚本断言。第一个文件已成功执行保存,但找不到第二个文件。

def fileName = "C:\\<mydirectory>"+'/test.pdf'
def fileName1 = "C:\\<mydirectory>"+'/test1.pdf'
def response = messageExchange.response
assert null != response, "response is null"
def outFile = new FileOutputStream(new File(fileName))
def outFile1 = new FileOutputStream(new File(fileName1))
def ins = messageExchange.responseAttachments[0]?.inputStream
def ins1 = messageExchange.responseAttachments[0]?.inputStream

if (ins) {
com.eviware.soapui.support.Tools.writeAll(outFile, ins)
}
ins.close()
outFile.close()

if (ins1) {
com.eviware.soapui.support.Tools.writeAll(outFile1, ins)
}
ins1.close()

outFile1.close()

0 个答案:

没有答案