如何将现有的SOAP请求消息导入SoapUI?
发布时间:2020-12-15 08:34:22 所属栏目:Java 来源:网络整理
导读:我有一堆 XML格式的SOAP请求消息.有没有办法将它们导入SoapUI项目? 我想导入它们并将“测试请求”测试步骤添加到现有的测试用例中. 解决方法 一种简单且更自动的方法是使用groovy脚本从您拥有xml请求文件的目录中自动创建testStep请求: 手动创建TestCase.
我有一堆
XML格式的SOAP请求消息.有没有办法将它们导入SoapUI项目?
我想导入它们并将“测试请求”测试步骤添加到现有的测试用例中. 解决方法
一种简单且更自动的方法是使用groovy脚本从您拥有xml请求文件的目录中自动创建testStep请求:
>手动创建TestCase. 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()) } 希望这可以帮助, (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |