Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to fetch datasource values to xml payload

mdsheeraz
mdsheeraz Posts: 25
edited May 29 in Virtualize

Hi,

We have a xml payload as below, would need to add the values to the payload from datasource.

currently it is just fetching first row's data and adding same value in 3 different name field, instead of that it should get the value from 2nd row for 2nd value and so on.

sample payload :

<Meter>
       <Names>
        <name>${name}</name>
       </Names>
      <Names>
        <name>${name}</name>
       </Names>
       <Names>
        <name>${name}</name>
       </Names>
</Meter>

Answers

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    Data source correlation matches an incoming request to a row of data in a data source. Is there a reason that the data can't be formatted to be in a single row? The way the example is presented is the response always returning data from all the data source rows?

  • mdsheeraz
    mdsheeraz Posts: 25

    Yes, in the data source rows have selected as all, from the query it fetches 3 records having different names in a name column.
    and, in my request xml payload there will be 3 name fields and it should retrieve the 3 datasource values from each rows sequentially and construct the request payload.

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    Is this a Database data source? Data sources will always select the first match when being used for correlation so there is only ever one row of data that the response is using at a time. Perhaps a Database tool could be used to run the query and then select multiple values out into different columns so that they could be used from the response payload.

  • mdsheeraz
    mdsheeraz Posts: 25

    Yes, using database data source. I tried with the DB tool but in my actual scenario, request payload has more than 16 fields of names in the xml, using DB tool and extracting the multiple values and assigning it to each fields quite lengthy process.

    Is there any other way to fetch the values from each rows sequentially in a iterative way?

  • mdsheeraz
    mdsheeraz Posts: 25

    Attaching the request payload for better understanding of requirement.

    from the db datasource we will be fetching meter details irrespective of any number of meters which are available in the DB for each meter it will fetch 8 rows which has different values.

    for ex: if it retrieves 2 meters data there will be total 16 rows.

    And, using these values xml payload should construct, in a single request payload it uses 8 rows data values from DB and it will construct payload for 1 meter.
    likewise if it is 2 meters then another payload should construct with the remaining 8 rows of data values and so on.

    Expectation is if we trigger a test suite, datasource should retrieve the data and construct the request payload based on the meter's data and execute one by one using rest client.