如何将现有的SOAP请求消息导入到SoapUI?
将每个复制/粘贴到一个新请求中,然后右键单击每个请求并将它们添加到您的测试用例中。
或者在请求视图中打开上下文菜单时选择“从...加载”。
另一种选择是:调用部分
- 有一个请求
- 打开的soapUI项目XML文件
- 搜索CON创建的soapUI项目:请求与您自己的XML请求
- 保存并重新加载项目在soapui
一个简单和更自动化的方式来做到这一点是使用Groovy脚本来自动创建一个目录,你有你的XML请求文件的一步步测试要求:
- 手动创建一个TestCase。
- 添加一个空的TestStep请求,我们将用它作为模板来创建其他请求。
- 添加一个groovy testStep,它使用下面的代码导入所有文件,并执行它以创建testSteps。
你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())
}
希望这有助于
“your_xml_request_directory”是绝对路径吗?或者,如果它是一个相对路径,它与哪个目录相对? – 2016-09-01 13:36:50
@HuukchanKwon在我的例子中'/ your_xml_request_directory /'指的是一个绝对路径。我不知道,但我想如果你使用相对路径,它是相对于soapui执行目录。 – albciff 2016-09-01 13:40:23
这就是我要去没有看到其他选项。将会回落到这个如果有效 – 2016-04-21 23:12:03