java soapui 发送xml,如何将现有的SOAP请求消息导入SoapUI?

这篇博客介绍了如何通过Groovy脚本来自动化地将一堆XML格式的SOAP请求消息导入到SoapUI项目中。首先手动创建一个TestCase和一个空的TestStep作为模板,然后利用WsdlTestRequestStepFactory创建工厂,遍历XML请求文件目录,为每个文件创建新的TestStep,并设置请求内容。这样可以有效地将多个SOAP请求添加到现有的测试用例中。
摘要由CSDN通过智能技术生成

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

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

解决方法:

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

>手动创建TestCase.

>添加一个空的TestStep请求,我们将其用作模板来创建其他请求.

>添加一个groovy 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())

}

希望这可以帮助,

标签:java,web-services,wsdl,soapui

来源: https://codeday.me/bug/20190730/1582087.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值