简体   繁体   English

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

[英]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请求:

  1. Create a TestCase manually. 手动创建TestCase。
  2. Add an empty TestStep request which we will use as a template to create the other requests. 添加一个空的TestStep请求,我们将其用作模板来创建其他请求。
  3. Add a groovy testStep which imports all files using the code below, and execute it in order to create the testSteps. 添加一个groovy testStep,它使用下面的代码导入所有文件,并执行它以创建testSteps。

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: 另一种选择是:

  1. Create a soapui project with one request 使用一个请求创建一个soapui项目
  2. Open the soapui-project XML file 打开soapui-project XML文件
  3. Search for con:call part 搜索con:call part
  4. Duplicate it and replace the con:request with your own XML request 复制它并用您自己的XML请求替换con:request
  5. Save and reload the project in soapui 在soapui中保存并重新加载项目

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java中使用SoapUI生成示例SOAP请求 - How to generate example SOAP request with SoapUI in java 如何向诸如SoapUI的端点或WSDL发出SOAP请求? - How to make a SOAP Request to an Endpoint or WSDL like SoapUI? 如何在SoapUI工具的SOAP请求中指定复杂的数据类型输入 - How to specify a complex datatype input in a SOAP Request in SoapUI tool 如何将现有的SOAP请求发送到现有的WSDL - How to send existing SOAP Request to Existing WSDL 如何将现有XML文件作为请求导入到Java中的SoapUI API? - How to import existing XML files as requests to SoapUI API in JAVA? 如何将Spring Ws中的Soap请求消息发送到接受Soap请求消息的服务器? - How to send Soap request messages in Spring Ws to a Server which accepts Soap request messages? 如何捕获Java中的SOAP请求和响应消息? - How can I capture SOAP request and response messages in Java? 如何在Spring Boot中将肥皂请求和带有自定义消息的响应记录到文件中? - How to log soap request and response with custom messages to file in Spring Boot? 解析从SOAPUI发送的SOAP请求-使用Axis2 Servlet - Parsing SOAP request sent from SOAPUI - using Axis2 Servlet 与Java中的SOAPUI集成时处理SOAP请求参数 - Manipulating SOAP request paramenters when Integrating with SOAPUI in Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM