user136252
user136252

Reputation: 41

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>

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

Upvotes: 1

Views: 23093

Answers (1)

albciff
albciff

Reputation: 18507

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

enter image description here

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.

enter image description here

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,

Upvotes: 3

Related Questions