如何将现有的SOAP请求消息导入SoapUI?
作者:互联网
我有一堆XML格式的SOAP请求消息.有没有办法将它们导入SoapUI项目?
我想导入它们并将“测试请求”测试步骤添加到现有的测试用例中.
解决方法:
一种简单且更自动的方法是使用groovy脚本从您拥有xml请求文件的目录中自动创建testStep请求:
>手动创建TestCase.
>添加一个空的TestStep请求,我们将其用作模板来创建其他请求.
>添加一个groovy testStep,它使用下面的代码导入所有文件,并执行它以创建testSteps.
groovy代码执行之前的SOAPUI如下所示:
和必要的groovy代码:
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestRequestStepFactory
import groovy.io.FileType
// get the current testCase to add testSteps later
def tc = testRunner.testCase
// get the testStep as template to create the other requests
def tsTemplate = tc.getTestStepByName("TestRequest template")
// create the factory to create testSteps
def testStepFactory = new WsdlTestRequestStepFactory()
def requestDir = new File("/your_xml_request_directory/")
// for each xml file in the directory
requestDir.eachFileRecurse (FileType.FILES) { file ->
def newTestStepName = file.getName()
// create the config
def testStepConfig = testStepFactory.createConfig( tsTemplate.getOperation(), newTestStepName )
// add the new testStep to current testCase
def newTestStep = tc.insertTestStep( testStepConfig, -1 )
// set the request which just create with the file content
newTestStep.getTestRequest().setRequestContent(file.getText())
}
希望这可以帮助,
标签:java,web-services,wsdl,soapui 来源: https://codeday.me/bug/20190730/1582087.html