【问题标题】:SOAP - parsing variable from groovy to soap requestSOAP - 将变量从 groovy 解析为肥皂请求
【发布时间】:2017-10-19 11:50:46
【问题描述】:

我是 SOAP 新手,需要帮助 :) 我有一个 SOAP 请求,我想运行五次,我需要将变量从 groovy 中的 for 循环传递给请求。

例子:

对于 (i=1;i

带有传递 i 变量的 SOAP 请求

}

另一个问题:有什么办法,如何组合变量?我有一个带有一些数据的属性,我需要将这些数据与传递的 i 变量结合起来 示例:

${adress#City + i 变量}

感谢您的回复。

【问题讨论】:

    标签: variables for-loop soap groovy


    【解决方案1】:

    假设 my_prop 是您传递给您的肥皂请求的值

    for (index=1;index<5;index++)  
    {
        // set the index value in the property
        testRunner.testCase.setPropertyValue(my_prop, index.toString())
        // run your SOAP request
        testRunner.runTestStepByName("my_soap_test_step")
    }
    

    对于你的第二个问题,你可以做

    new_prop = context.expand( '${#TestCase#old_prop}' ) + index.toString()
    

    【讨论】:

    • 谢谢。那个工作。我还有一个问题:如何在 XML 请求中合并变量?我需要将此&lt;gser:Name&gt;${adress#Name}&lt;/gser:Name&gt; 与传递的号码合并。结果应该是&lt;gser:Name&gt;${adress#Name1}&lt;/gser:Name&gt; 这可能吗? &lt;gser:City&gt;$(${adress#City}+${#TestCase#my_prop})&lt;/gser:City&gt;
    • 好吧,我对 XML 不是很熟悉,请使用我的答案中的 new_prop 示例来创建中间变量并尝试使用它。
    • 问题已解决 :) 没关系:&lt;gser:City&gt;${adress#City${#TestCase#my_prop}}&lt;/gser:City&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多