简体   繁体   English

SoapUI 中的 Groovy 脚本

[英]Groovy Script in SoapUI

When I'm running the following script in my SOAPUI, I'm getting error related to HTTPBuilder.当我在我的 SOAPUI 中运行以下脚本时,我收到了与 HTTPBuilder 相关的错误。 Error is still there even after adding @Grab statement.即使添加了@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
}

Any solution to run this groovy script in SOAP UI.在 SOAP UI 中运行此 groovy 脚本的任何解决方案。

SoapUI does not come with HTTPBuilder . SoapUI 不附带HTTPBuilder Further, since the Groovy engine has already been started in a running SoapUI instance, your @Grab annotation will not work.此外,由于 Groovy 引擎已经在运行的 SoapUI 实例中启动,您的@Grab注释将不起作用。

In order to extend the functionality of SoapUI, you must download the.jar and all dependencies manually, and place them in $SOAPUI_HOME/bin/ext folder.为了扩展 SoapUI 的功能,您必须手动下载.jar 和所有依赖项,并将它们放在$SOAPUI_HOME/bin/ext文件夹中。 You will need to restart SoapUI for this to take effect.您需要重新启动 SoapUI 才能使其生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM