cancel
Showing results for 
Search instead for 
Did you mean: 

XPATH Query - trap GET Request Response Via Data Sink Step Query

SOLVED
Community Hero

XPATH Query - trap GET Request Response Via Data Sink Step Query

Hi,

 

I'm struggling to capture the WHOLE response of an GET response to save to a Data Sink - the response is in XML.

I have a POST response and I'm saving this response to a Data Sink - the response is in JSON and I AM capturing the WHOLE POST response.

 

SO - for my response in JSON I can capture the whole response, for my response in XML I can only grab the specific tag value - I need to capture the WHOLE response rather than just a single tag.

 

I have the following hierarchy

 

Datasource(Directory) multiple files on local drive - fileContents property
POST Request (submitting fileContents property for each file)
DataSink1(records POST response to a file)
PropertyTransfer step (JSONPATH grabs POST response content to DataSink1)
GET Request (submits using CustRefID from previous POST request)
PropertyTransfer step (XPATH grabs GET response content to DataSink2)
DataSink2(records GET response to a file)
DataLoop (loops round to pick up next file on drive to start test case again)

As you can see from the hierarchy I am using Property Transfer and Data Sink steps to capture the responses of both a POST and a GET request.

 

As stated above - I can capture the WHOLE response of the POST (which is in JSON) but I can't capture the WHOLE response of the GET (which is in XML) 

 

 

 

The POST Response is JSON (Path Language setting on the Property Transfer is JSONPATH)

The GET Response is XML (Path  Language setting on the Property Transfer is XPATH)

 

The difference between the 2's responses is that the POST's response is JSON, whereas the GET's response is XML - and I'm assuming this is the root cause of why I can capture the whole response in the Data Sink for the POST, but I can't capture the whole response in the Data  Sink for the GET.

 

The XML structure in the GET response is as follows:

 

 

<results>
<result>
<child1>value</child1>
<child2>value</child2>
<child3>value</child3>
<child4>value</child4>
</result>
</results>

 

 

I'm wondering what I am doing wrong - does anyone know the reason why I cannot capture the whole GET response to the Data Sink like I can with the POST response?

 

I'm assuming I need to change the XPATH setting but I've searched around but I can't seem to find the XPATH for 'all child nodes below a parent'

 

When I use the XPATH 

//results[1]/result[1]

 

The transferred value is blank.

 

Can anyone give me any an idea how to change the XPATH so that ALL the XML is passed to the Data Sink?

 

It's really annoying because the POST response is JSON and I can grab all the results quite easily!

 

Thanks!

 

richie

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
3 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

How about
//*:results


Regards,
Rao.
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

Sorry - didn't respond cos I've been executing tests for 12 hours a day for the last 2 weeks.

 

@rao - thanks - your answer really helped out!

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

Glad that it helped and thank your coming back and accepting the solution.


Regards,
Rao.
5 REPLIES 5
Super Contributor

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

Try deselecting 'Transfer text content' only option in the property transfer.

 

https://www.soapui.org/functional-testing/properties/transferring-properties.html

  • Transfer text content - Only text content will be transferred. No structural elements will be preserved
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

@richie: You can try the following adjustment to xpath as seen below. That might help.

 

//results[1]/result[1]/node()



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

How about
//*:results


Regards,
Rao.
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

Sorry - didn't respond cos I've been executing tests for 12 hours a day for the last 2 weeks.

 

@rao - thanks - your answer really helped out!

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Community Hero

Re: XPATH Query - trap GET Request Response Via Data Sink Step Query

Glad that it helped and thank your coming back and accepting the solution.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors