开发者

SOAP UI -Passing and Testing JSON Response as Request to another JSON

开发者 https://www.devze.com 2023-03-12 06:33 出处:网络
I have 2 json rest services my condition to t开发者_StackOverflowest them is like, I will give request to one json service which in turn give me the response which I will use as one of the json input

I have 2 json rest services my condition to t开发者_StackOverflowest them is like, I will give request to one json service which in turn give me the response which I will use as one of the json input object for 2nd json service. For Example, My json1 has given response as 221 which I will use that and frame json object like

{id:221,name:'test Json'}

and pass it over to json2 where 221 is the response from json1. Will that be possible? Can anyone please explain?

Thanks,

Karthik


Yes, use the Property transfer functionality in SOAPUI. Store your response in a variable (property) and pass it over with standard format ${#Variable} to next test step


There are multiple ways to achieve this 1st one is:

  1. Use property transfer to get the value from the response and store it in the properties step.
  2. Use ${Properties#propName} to fetch the value of the property into your request where you want to use the value.

2nd approach will be to use groovy script

  1. Add a groovy script step after your 1st request and Use jsonParser to parse the response and fetch the desired value and store it in properties step
  2. Same as method 1's step 2.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号