Forum Discussion
Hi,
Where I need to 'grab' a value from a service response, I tend to use a Groovy script. You can access values in a response by specifying the test step and response value of interest.
For example, in your test, you have a test step to call a web service. After that step, add a Groovy script test step. In the licensed version (not sure about the open source version), you can right-click in the Groovy script step and a context menu pops up. On this menu, select 'get data'. Get data allows you to select a test step and you can then drill-down to the value of interest. Once you find the value and you click 'OK', the Groovy script to access the value of interest is displayed. You can then report this value, save it somewhere, or add it to Custom Properties for use later.
If your SoapUI does not have the 'get data', then it's a little more tricky. You will need to use context.expand...
def id = context.expand( '${yourTestStep#Response#declare namespace ns1=\'urn:yourOrder:domain:1\'; //ns1:requestResponse[1]/ns1:requestResult[1]/ns1:someDto[1]/ns1:id[1]}' )
The above creates a variable called id which looks in the test step and uses XPath to drill down to the response tree and ultimately the id. The above is just an example. You'll need to look at your response and the namespaces to be able to use XPath.
Without a response example in your original question, it's difficult to help further.
Related Content
- 2 years ago
- 12 years ago
- 4 years ago
- 6 years ago
Recent Discussions
- 18 hours ago
- 4 days ago
xml to soap
Solved4 days ago- 5 days ago