如何在单个 groovy 脚本中访问所有 soap 请求
How to access all soap request in a single groovy script
我正在编写一个 groovy 脚本来一步测试我的所有服务。
我导入了 WSDL,然后自动生成了所有 SOAP 请求。
我想减少一项一项地测试所有 SOAP 服务的手动工作。
所以,如果可能的话,我想通过 groovy 完成。
从此处开始,在 addressScript 中 - 我想稍后访问所有测试用例中的所有 SOAP 请求。那么是否可以通过上下文中的一些循环来实现它..?下面是我正在尝试的示例代码。
我的主要动机是减少逐一测试所有 SOAP 请求的所有手动工作。
import org.apache.commons.httpclient.methods.PostMethod;
import org.w3c.dom.*;
class Example {
static void main(String[] args) {
String serviceInput="";
PostMethod post = new PostMethod(");
post.setRequestHeader("Accept", "application/soap+xml,application/dime,multipart/related,text/*");
post.setRequestHeader("SOAPAction", "");
def req = context.testCase.getTestStepAt(context.currentStepIndex - 1).httpRequest.requestContent
log.info req
// here i want to access all the SOAP requests in loop , and to test all the services in sequence
}
}
从您所附的图片来看,您的案例似乎正在使用 SOAP
请求步骤。
这里是Groovy Script
。
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Loop thru all the test cases of test suite
context.testCase.testSuite.testCaseList.each { testKase ->
//Loop thru all the test steps of each test case
testKase.testStepList.each { step ->
//Check if the request type is SOAP
if (step instanceof WsdlTestRequestStep) {
//Get the request of test step
def stepRequest = step.getPropertyValue('Request')
log.info "Request of step ${step.name} is :\n ${stepRequest}"
} else {
log.info 'Ignoring step as it is not SOAP request type step'
}
}
}
不太确定,收到请求后您想做什么。无论如何,stepRequest
变量将包含请求数据,现在只是记录,如您在上面的代码中所见。
我正在编写一个 groovy 脚本来一步测试我的所有服务。
我导入了 WSDL,然后自动生成了所有 SOAP 请求。
我想减少一项一项地测试所有 SOAP 服务的手动工作。
所以,如果可能的话,我想通过 groovy 完成。
从此处开始,在 addressScript 中 - 我想稍后访问所有测试用例中的所有 SOAP 请求。那么是否可以通过上下文中的一些循环来实现它..?下面是我正在尝试的示例代码。
我的主要动机是减少逐一测试所有 SOAP 请求的所有手动工作。
import org.apache.commons.httpclient.methods.PostMethod;
import org.w3c.dom.*;
class Example {
static void main(String[] args) {
String serviceInput="";
PostMethod post = new PostMethod(");
post.setRequestHeader("Accept", "application/soap+xml,application/dime,multipart/related,text/*");
post.setRequestHeader("SOAPAction", "");
def req = context.testCase.getTestStepAt(context.currentStepIndex - 1).httpRequest.requestContent
log.info req
// here i want to access all the SOAP requests in loop , and to test all the services in sequence
}
}
从您所附的图片来看,您的案例似乎正在使用 SOAP
请求步骤。
这里是Groovy Script
。
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
//Loop thru all the test cases of test suite
context.testCase.testSuite.testCaseList.each { testKase ->
//Loop thru all the test steps of each test case
testKase.testStepList.each { step ->
//Check if the request type is SOAP
if (step instanceof WsdlTestRequestStep) {
//Get the request of test step
def stepRequest = step.getPropertyValue('Request')
log.info "Request of step ${step.name} is :\n ${stepRequest}"
} else {
log.info 'Ignoring step as it is not SOAP request type step'
}
}
}
不太确定,收到请求后您想做什么。无论如何,stepRequest
变量将包含请求数据,现在只是记录,如您在上面的代码中所见。