Forum Discussion

mangeshr's avatar
mangeshr
Regular Visitor
7 years ago

How to pickup specific row based on index or id from given data source in soap response.

Hi,

I have defined one datasource in a Grid as below
id name city
-------------------
12 ABC Pune
15 XYZ Mumbai
18 EFG Delhi

 

Based on input request id = 15 xml response should get generated dynamically which will have all the detail of id 15
eg

id name city
-------------------
15 XYZ Mumbai

${#MockResponse#name} this syntax works perfectly but picks up any random value from given table. below is the response snippet
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:examples:helloservice">
<soapenv:Header/>
<soapenv:Body>
<urn:sayHelloResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<greeting xsi:type="xsd:string">${#MockResponse#id}</greeting>
<greeting xsi:type="xsd:string">${#MockResponse#name}</greeting>
<greeting xsi:type="xsd:string">${#MockResponse#city}</greeting>
</urn:sayHelloResponse>
</soapenv:Body>
</soapenv:Envelope>

 

How to pickup specific row based on index or id from given data source in soap response.

 

https://support.smartbear.com/readyapi/docs/soapui/steps/data-source.html#multirow
Above link has given example of how to pick the specific row.
To refer to the City property of the second row in the iteration, use ${DataSource#City::1}

 

but above syntax doesn't work.

can you please help with an example?

1 Reply

  • StevenColon's avatar
    StevenColon
    SmartBear Alumni (Retired)

    Thank you for posting to our Community Forum.

     

    There seems to be a bit of confusion on how Datasources are implemented in ServiceV. It is meant to allow users to return a variety of responses but it merely iterates through each row of the grid. You cannot select any specific row.

     

    Here is our documentation on this so that you can learn more: https://support.smartbear.com/readyapi/docs/servicev/configure/datasources.html

     

    If you need specific data passed along depending on a request, You can do one of two things.

    1. Create a response for each possibility and use the script dispatching strategy to select the appropriate response depending on what is in the request. https://support.smartbear.com/readyapi/docs/servicev/configure/dispatch/script.html
    2. If you have alot of possibilities, then the best option is to implement a database and create a single response that uses a groovy script to query the DB. I cannot provide an example script since there are different DB providers but you shouldn't have an issue looking up how to write a script to connect to any DB provider.

     

    Let me know if you have any questions/concerns.