SOAP-UI - How to pass parameter from variable

試著忘記壹切 提交于 2019-12-11 12:13:00

问题


<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>

What I would like to know is how I can pass a variable instead of some value1,some value2,some value3 and how can I set these variable values from a response of another webservice

Thanks


回答1:


You could achieved this using properties, there are some scopes for the properties project, testCase, testSuite, etc. You've to set the property name and the value at desired scope and then you can use it directly in your request using the follow notation ${#scope#propertyname} for example if you've a property called parameter1 at testCase scope, you can use it in your request as follows:

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

For more info take a look at the documentation.

As you also ask to fill this property from the response of other testStep a possible way to achieved is using property transfer step, at this step you've to set:

  1. Source: TestStep and it's property (response, request, etc.).
  2. XPATH to perform against the source to get the value.
  3. The target property where you put the recovered value: scope and property name.

I expand the second part with an example, so imagine you've a testStep which has myRequest as name and its responds looks like:

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

You want to get the value of <anotherText> node to reuse it so the XPath to get it from the response //*:anotherText. Then you put the value inside a property called parameter1 at TestCase level (i.e the testCase is named TestCase 1). In this scenario the property transfer step will be:

  • Source: myRequest Property: Response
  • XPATH: //*:anotherText
  • Target: TestCase 1 Property: parameter1

For more info take a look at the documentation here and here

Hope it helps,



来源:https://stackoverflow.com/questions/32066042/soap-ui-how-to-pass-parameter-from-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!