【问题标题】:How to pass parameter to SOAP request in SOAPUI如何在 SOAPUI 中将参数传递给 SOAP 请求
【发布时间】:2018-01-09 20:37:52
【问题描述】:

我是soap和soapui的新手,我正在尝试创建一个测试用例,在该测试用例中我将多次发送相同的请求(XML附件)(大约500次),问题是每次我都需要增加/更改请求中的值(id)。
因此,我想知道是否可以将此参数传递给附加的 xml 文件?或者如果有其他方法来做测试用例。
先感谢您
更新
这是xml文件的内容:

<mod:sendMSG xmlns:mod="http://test.soap/service/model">
  <id>${#Project#parameter1}</id>
  <date>2016-04-03T04:03:00</date>
  <infos>
        <firstName>AT </firstName>
        <lastName>AT </lastName>
        ......
  </infos>
</mod:sendMSG>

包含在soap请求中,如下图所示:

【问题讨论】:

  • 请显示xml sn-p 你想在哪里增加?

标签: soap soapui


【解决方案1】:

测试步骤:

  1. Groovy 脚本

  2. SOAP 请求(已禁用)

我禁用了 SOAP 请求,因为它在脚本已经循环请求 x 次后再次运行。

Groovy 脚本:

int loops = 500;

for ( iter in 1..loops ) {

    //Overwrite the 'parameter1' property at project level
    testRunner.testCase.testSuite.project.setPropertyValue("parameter1", iter.toString())

    //log.info("iter: " + testRunner.testCase.testSuite.project.getPropertyValue("parameter1"));

    // Run the teststep named 'SOAP Request'
    def testStep = testRunner.testCase.testSteps['SOAP Request'];
    testStep.run( testRunner, context )
}

现在您应该可以运行您的 TestCase。我建议之前保存你的项目,我遇到了一些问题,SoapUI 在运行时崩溃了。

【讨论】:

  • 感谢您的回复,但是有一个问题,我上面给出的xml包含在请求中,因此${#Project#parameter1}没有被相应的值替换。查看更新
  • 不幸的是,我没有将文件附加到请求中的经验,希望其他人可以在这方面为您提供帮助。为什么必须从文件中注入该 xml,它不能只是 SoapUI 中请求的一部分吗?
  • 谢谢,但是需要发送xml文件,所以附加到请求中。
猜你喜欢
  • 2016-08-01
  • 1970-01-01
  • 2023-04-03
  • 2020-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-15
  • 1970-01-01
相关资源
最近更新 更多