让soapUI在响应的Attachments选项卡中显示附件 [英] Getting soapUI to show attachment in attachments tab for a response

查看:23
本文介绍了让soapUI在响应的Attachments选项卡中显示附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过HTTP GET返回文件的REST服务。

我已经在响应中设置了这些标头(在服务器上),下载在任何浏览器中都能正常运行:
Content-Length
Content-Type
Content-Disposition


然而,在soapUI中,它只是将二进制输出打印到响应窗口--我希望将文件放到底部的"Attachments"选项卡中。

我已尝试多部分/混合,但无济于事。

有谁知道我应该如何让服务器形成响应,以便soapUI将文件放到附件选项卡中?

谢谢!

推荐答案

我不知道如何将文件放入"附件"选项卡中,但我知道您可以通过groovy将二进制输出转换为文件。

您可以尝试此脚本,只需填写三个变量扩展名、名称、extBase64。

import org.apache.commons.codec.binary.Base64
def extension = (##extension of your file##)
def name = (##name of your file ##) 
def textBase64 =(##binary output from your request##) 


// Access element Base64-encoded text content 
String tempFilename = "${name}.${extension}"
def b64 = new Base64()
def TextBytes = b64.decode(textBase64.getBytes())

// Output text into a temporary file
def File = new java.io.File(tempFilename)
FileOutputStream fos = new java.io.FileOutputStream(File)
fos.write( TextBytes )
fos.flush()
fos.close()
log.info "File stored as: ${File.getCanonicalPath()}"

可能有更好的脚本,但这个适合我

这篇关于让soapUI在响应的Attachments选项卡中显示附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆