如何将现有的 SOAP 请求消息导入到 SoapUI?

发布于 2024-09-07 20:44:04 字数 95 浏览 2 评论 0原文

我有一堆 XML 格式的 SOAP 请求消息。有没有办法将它们导入到 SoapUI 项目中?

我想导入它们并将其作为“测试请求”测试步骤添加到现有的测试用例中。

I have a bunch of SOAP request messages in XML format. Is there a way to import them to a SoapUI project?

I want to import them and add as "Test Request" Test Step to an existing Test Case.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

烈酒灼喉 2024-09-14 20:44:04

一种简单且更自动的方法是使用 groovy 脚本从包含 xml 请求文件的目录自动创建 testStep 请求:

  1. 手动创建 TestCase。
  2. 添加一个空的 TestStep 请求,我们将使用该请求作为模板来创建其他请求。
  3. 添加一个常规 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())
}

希望这有帮助,

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:

  1. Create a TestCase manually.
  2. Add an empty TestStep request which we will use as a template to create the other requests.
  3. Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps.

Your SOAPUI before groovy code execution looks like:

enter image description here

And the necessary groovy code:

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,

萌无敌 2024-09-14 20:44:04

将每个请求复制/粘贴到新请求中,然后右键单击每个请求并将它们添加到您的测试用例中。

Copy/paste each into a new request, then right click on each request and add them to your test case.

雪花飘飘的天空 2024-09-14 20:44:04

或者在请求视图中打开上下文菜单时选择“加载自...”。

Or select "Load from..." when opening the context menu in the request view.

浮光之海 2024-09-14 20:44:04

另一种选择是:

  1. 使用一个请求创建一个soapui项目
  2. 打开soapui-project XML文件
  3. 搜索con:call部分
  4. 复制它并用您自己的XML请求替换con:request
  5. 在soapui中保存并重新加载项目

Another option is:

  1. Create a soapui project with one request
  2. Open the soapui-project XML file
  3. Search for con:call part
  4. Duplicate it and replace the con:request with your own XML request
  5. Save and reload the project in soapui
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文