SOAP-UI - 如何从变量传递参数

SOAP-UI - How to pass parameter from variable

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xxx="http://xxx.call/">
   <soapenv:Header/>
   <soapenv:Body>
      <cotf:call_XXX>
         <!--Optional:-->
         <arg0>
            <!--Optional:-->
            <parameter1>some value1</parameter1>
            <!--Optional:-->
            <parameter2>some value2</parameter2>
            <!--Optional:-->
            <parameter3>some value3</parameter3>
         </arg0>
      </cotf:call_XXX>
   </soapenv:Body>
</soapenv:Envelope>

我想知道的是如何传递一个变量而不是某些值 1、某些值 2、某些值 3,以及如何根据另一个网络服务的响应设置这些变量值

谢谢

您可以使用属性实现此目的,属性项目、testCase、testSuite 等有一些范围。您必须在所需范围内设置 属性 名称和值,然后您可以使用它直接在您的请求中使用以下符号 ${#scope#propertyname} 例如,如果您在 testCase 范围内有一个名为 parameter1 的 属性,您可以在您的请求中使用它,如下所示:

...
<arg0>
    <!--Optional:-->
    <parameter1>${#TestCase#parameter1}</parameter1>
...

有关更多信息,请查看 at the documentation

正如您还要求从其他 testStep 的响应中填充此 属性 一种可能的实现方法是使用 属性 传输步骤 ,在此您要设置的步骤:

  1. 来源:TestStep,它是 属性(响应、请求等)。
  2. XPATH 对源执行以获取值。
  3. 您放置恢复值的目标 属性:范围和 属性 名称。

我用一个例子扩展了第二部分,假设你有一个以 myRequest 作为名称的 testStep,它的响应如下:

<myResponse>
   <someValue>MyValue</someValue>
   <anotherText>someText</anotherText>
</myResponse>

您想获取 <anotherText> 节点的值以重用它,以便 XPath 从响应 //*:anotherText 中获取它。然后将值放入 属性 中 TestCase 级别的 parameter1(即测试用例命名为 TestCase 1)。在这种情况下,属性 传输步骤将是:

  • 来源:myRequest 属性:Response
  • XPATH://*:anotherText
  • 目标:TestCase 1 属性:parameter1

有关详细信息,请查看文档 here and here

希望对您有所帮助,