如何在 groovy 脚本中访问 SOAP 请求 - SOAP UI

how to access the SOAP request in the groovy script - SOAP UI

我正在编写 groovy 脚本来使用 SOAP Web 服务。首先我导入了我的 SOAP 中的 WSDL 并创建了一个项目。

然后所有的SOAP请求都会自动生成。

现在正在尝试编写 groovy 以使用生成的 SOAP 请求调用 SOAP 服务。

现在这是我的 groovy 脚本

import org.apache.commons.httpclient.methods.PostMethod;
import org.w3c.dom.*;


class Example {
   static void main(String[] args) {

String serviceInput="";
PostMethod post = new PostMethod("http://server:30280/so_ws/SO?WSDL");
post.setRequestHeader("Accept", "application/soap+xml,application/dime,multipart/related,text/*");
post.setRequestHeader("SOAPAction", "");

// access CreateNote SOAP request here to call PostMethod
   }
}  

我想访问在 SOAP UI - CreateNote 中生成的同一个 SOAP 请求。 我怎样才能访问它?

我的实际要求是访问 groovy 脚本中的所有 SOAP 请求 - 这样我就可以编写一个脚本来一次测试所有 SOAP 服务,并且也可以根据需要按顺序测试

这是 Groovy Script,它从 同一测试用例的前一步 获取 请求 就像你有你的当前测试用例。

脚本

def req = context.testCase.getTestStepAt(context.currentStepIndex - 1).httpRequest.requestContent
log.info req