当我在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中运行这个古怪的脚本。
SoapUI没有配备 HTTPBuilder
. 此外,由于Groovy引擎已经在运行中的SoapUI实例中被启动,你的 @Grab
注释将无法使用。
为了扩展SoapUI的功能,你必须下载.jar和 所有附属物 手动,并将其放入 $SOAPUI_HOME/bin/ext
文件夹。您需要重新启动SoapUI才能生效。