Ask a Question

How to get response property value and use it as next step input

Occasional Contributor

How to get response property value and use it as next step input

Version SoapUI 5.3 


  1. The first step Get country by country code (I input “in”, and I should get country name “India”)
  2. I want to user the country name “India” as input country name for the second step

How do I do it with groovy


I try the following code, but it is not work


Get value from the first steps


def responseCountry = testRunner.testCase.testSteps['GetCountryByCountryCode'].getPropertyValue("Name")


Set responseCountry as property in second stepsSoapUI_Pass_Perpority1.PNG 



Community Hero

Looks like this question is also posted here


There is no need to have an additional groovy step. Instead add a Script Assertion for the first request test step



//Check if there is repose
assert context.response, 'Response is empty or null'
def lookpcode = context.expand('${#TestCase#CountryCode}')
def dataSet = new XmlSlurper().parseText(context.response).'**'.find{ == 'GetCountryByCountryCodeResult')} as String
def countryName = new XmlSlurper().parseText(dataSet).'**'.find{ == 'countrycode' && it == lookpcode)}.parent().name.text() "Country name is ${countryName} where code is ${lookpcode}"
assert countryName, 'Country name empty or null'
context.testCase.setPropertyValue('COUNTRY_NAME', countryName)

In the next step, use property expansion where you needed the country name i.e., ${#TestCase#COUNTRY_NAME}

SmartBear Alumni (Retired)

Just FYI there's no need to use Groovy, a regular Property Transfer will work just as well.


Source (step): GetCountryByCountryCode
Property: Response
Path language: XPath


or just


(it seems that saxon picks the 1st matching node by default)

Target: The test step where you need to use the "India" value
Property: Request
Path language: XPath

Expression: An XPath expression for the target request field. For example, if you want to use the "India" value in the GetCurrencyByCountry operation that uses this request body

<soap:Envelope xmlns:soap="" xmlns:web="http://www.webserviceX.NET">

the request XPath expression would be



I attached a sample project to demonstrate the above.

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Occasional Contributor

Hi Helen,


Thank you! It is easy solution for it

Showing results for 
Search instead for 
Did you mean: