SoapUI中的Groovy脚本

问题描述 投票:1回答:1

当我在SOAPUI中运行以下脚本时,我得到了与HTTPBuilder相关的错误。即使添加了@Grab语句,错误仍然存在。

def http = new HTTPBuilder(serviceEndPoint)
def scanResultFile = new File(testRunner.testCase.getPropertyValue("ScanResultFile"))

http.request( POST ){ req ->

headers.'Connection' = 'Keep-Alive'
headers.'User-Agent' = 'SoapUI 4.5.1'
requestContentType = 'multipart/form-data'

ByteArrayBody bin = new ByteArrayBody(scanResultFile.readBytes(), "application/octet-stream", "jobResult");
StringBody info = new StringBody(testRunner.testCase.getPropertyValue("JsonScanResult"), "application/json", java.nio.charset.StandardCharsets.UTF_8);

MultipartEntity entity = new MultipartEntity()
entity.addPart("info", info);
entity.addPart("jobResult", bin)
req.entity = entity
}

有什么办法可以解决在SOAP UI中运行这个古怪的脚本。

rest groovy soapui
1个回答
0
投票

SoapUI没有配备 HTTPBuilder. 此外,由于Groovy引擎已经在运行中的SoapUI实例中被启动,你的 @Grab 注释将无法使用。

为了扩展SoapUI的功能,你必须下载.jar和 所有附属物 手动,并将其放入 $SOAPUI_HOME/bin/ext 文件夹。您需要重新启动SoapUI才能生效。

© www.soinside.com 2019 - 2024. All rights reserved.