Datasource Loop through JSON data
Hello,
I'm a new user to Soap UI NG pro, and I'm trying to create a test case that will call a resource catalog (rest/json) web service to return information about all the web services it knows about.
Here's an abbreviated example of the json response from the call to the resource catalog...
{
"AccountAggregationCompute_AMBBOS-LPD0F3": {
"ID": "AccountAggregationCompute_AMBBOS-LPD0F3",
"Service": "AccountAggregationCompute",
"Tags": [],
"Address": "http://endpoint:8750/xxx/Risk/BancWare/api/V201701/AccountAggregationCompute",
"Port": 8750,
"EnableTagOverride": false,
"CreateIndex": 0,
"ModifyIndex": 0
},
"AccountBalancingCompute_AMBBOS-LPD0F3": {
"ID": "AccountBalancingCompute_AMBBOS-LPD0F3",
"Service": "AccountBalancingCompute",
"Tags": [],
"Address": "http://endpoint:8750/xxx/Risk/BancWare/api/V201701/AccountBalancingCompute",
"Port": 8750,
"EnableTagOverride": false,
"CreateIndex": 0,
"ModifyIndex": 0
},
}
In the above, there are two web services defined. (You can see the full json response in the attached.)
After I get this response, I want to loop through each service node, and pull out the "Service" value for that node/group. I then want to use that service name in another GET request later in the test case.
Anyway, I thought I could use a Json Datasource w/ Loop structure to go through each json node, and return the Service value, but I can't seem to get this to work.
I defined a JSON DataSource that references the catalog response, but I can't seem to define the correct Row and Column Path to allow the DS Loop to later increment to the next Json node. It only processes the first node and then exits.
Do you know what the Row and Column (jsonpath) Paths should be here? I've tried many expressions, including $..Service, which does work at https://jsonpath.curiousconcept.com, but doesn't seem to work in my Datasource.
Maybe this isn't a valid approach? Should I be using a Groovy to parse this data instead?
Thanks for any feedback.
Jim
I dont know if this will help or not.
I was playing around with this a couple of week's ago - not specifically for work - I just hadn't used the groovy/xml/json datasources before so started to play around with the functionality.
I had a LOT of trouble with json datasource, perhaps I was doing something wrong (I also find xpath easier to read than jsonpath) - but I found setting it up was a lot easier if I used an XML datasource instead.
Despite the fact that the response of the request that I was using to populate my datasource was actually .json - I added the XML datasource in and specified the 'source property' dropdown on the XML datasource as 'ResponseAsXML'.
I was then able to build up a datasource of attributes successfully sourced from the response without too much trouble.
Just a suggestion,
Cheers,
richie