Forum Discussion

Syamala's avatar
Syamala
Occasional Contributor
16 years ago

How to pass data from response XML to request XML as input with groovy script

Hi,

I have a webservice which returns list of all players. the response is as below....



        Tendulkar Ganguly Dravid

     


Result data is  : Tendulkar, Ganguly and Dravid.

I want to pass each name as input to another webservice which gives me the age of each player.
i.e I want to pass all three values one after the other to another webservice which takes Player name as input and gives me the age of that particular players.

Could you please tell me the code how can I do this with Groovy script



The input XML for getAgeof Player webservice is


        Tendulkar
     



and response is :


        32
     



I want to automate using Groovy script. After getting results from webservice , I want to pass them to another and run automatically one after the other.

Please kindly share me the code

Appreciate your help.

Thanks
SYamala

2 Replies

  • sandi_siva's avatar
    sandi_siva
    Occasional Contributor
    Hi Syamala,
    Did you find any help on the topic you have posted?
    I am also looking for the same resolution.

    -Sandi
  • Hey,

    No need to write Groovy script for this, You can achieve using property transfer feature.

    Do this it should help,

    1. First add listAllPlayers and getAgeForPlayer to a test case and then insert property transfer step between the two requests.
    2. Add a property called NameTransfer (as you like)
    3. Select the source as listAllPlayers and property as response. Declare the xpath to capture the element from which you need data to be transferred.
    4.  Select the Traget as getAgeForPlayer and property as request. Declare the xpath to define the element to which you are transferring value.

    See the screen shot enclosed for your reference,

    Hope this helps,

    thanks,