[英]How to import existing SOAP request messages to SoapUI?
I have a bunch of SOAP request messages in XML format. 我有一堆XML格式的SOAP请求消息。 Is there a way to import them to a SoapUI project? 有没有办法将它们导入SoapUI项目?
I want to import them and add as "Test Request" Test Step to an existing Test Case. 我想导入它们并将“测试请求”测试步骤添加到现有的测试用例中。
An easy and more automatic way to do so is using a groovy script to automatically create the testStep request from a directory where you have you xml request files: 一种简单且更自动的方法是使用groovy脚本从您拥有xml请求文件的目录中自动创建testStep请求:
Your SOAPUI before groovy code execution looks like: groovy代码执行之前的SOAPUI如下所示:
And the necessary groovy code: 和必要的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())
}
Hope this helps, 希望这可以帮助,
Another option is: 另一种选择是:
将每个请求复制/粘贴到一个新请求中,然后右键单击每个请求并将它们添加到您的测试用例中。
或者在请求视图中打开上下文菜单时选择“从...加载”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.