Submit and vote on feature ideas.

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 use an XML Data Bank and Writable Data Source to extract multiple rows of data for later use

[Deleted User]
[Deleted User] Posts: 0 admin
edited December 2016 in SOAtest

The Goal

After completing this tutorial you should have a basic understanding of how to extract multiple values into corresponding data source rows that can later be iterated over for use in subsequent test steps.

The Use Case

For this use case we would like to request a list of all the books on the bookstore using the 'getItemByTitle' operation, from that response we would like to iterate over every book that is returned and pass the ID to the 'getItemById' operation, then we want to compare the name fields on both responses to verify that they remained the same. To do this we will need to extract the ID and Name of every book that is returned into individual data source rows so that the subsequent operation and assertion can be parameterized against each row of the data source.

The Tutorial

This tutorial uses the Bookstore web service provided by Parasoft. The Bookstore service is defined by a WSDL which is located here:
http://parabank.parasoft.com:80/parabank/services/store-01?wsdl

1) Add a SOAP Client to your test suite and configure it to the 'getItemByTitle' operation of the Bookstore web service.

a. Right-click the desired test suite and select "Add New > Test...", then select "SOAP Client" and click "Finish"
b. Under the "WSDL" tab set the "WSDL URL" to http://parabank.parasoft.com:80/parabank/services/store-01?wsdl then click "Refresh WSDL"
c. Under the "Request" tab set the "Operation" to 'getItemByTitle'
d. Check the box under "titleKeyword"
e. Save the SOAP Client

2) Add a Writable Data Source and configure it to accept the ID's and Name's from the 'getItemByTitle' operation

a. Right-click the desired test suite and select "Add New > Data Source...", then select "Writable" and click "Finish"
b. Give the data source a name
c. Set the "Writing Mode" to "Append" and "Per write access"
d. Check "First row specifies column names" then right-click the table and select "Insert Columns" then click "Ok"
e. Label the first column "id" and the second column "name"
f. Save the Writable

3) Extract the ID's and Name's using an XML Data Bank

a. Right-click the 'getItemByTitle' SOAP Client and select "Add Output > Response > SOAP Envelope > XML Data Bank" then click "Finish"
b. Run the 'getItemByTitle' SOAP Client
c. Right-click one of the "id" elements and select "Add XPath for all occurrences within book[]"
d. Double click the generated XPath and navigate to the "Data source column" page
e. Change the radio button to "Writable data source column" and set the dropdown to ": id" then click "Ok"
f. Right-click one of the "name" elements and select "Add XPath for all occurrences within book[
]"
g. Double click the generated XPath and navigate to the "Data source column" page
h. Change the radio button to "Writable data source column" and set the dropdwon to ": name" then click "Ok"
i. Save the XML Data Bank

4) Add a SOAP Client to your test suite and configure it to the 'getItemById' operation of the Bookstore web service.

a. Right-click the desired test suite and select "Add New > Test...", then select "SOAP Client" and click "Finish"
b. Under the "WSDL" tab set the "WSDL URL" to http://parabank.parasoft.com:80/parabank/services/store-01?wsdl then click "Refresh WSDL"
c. Under the "Request" tab set the "Operation" to 'getItemById'
d. Under the "id" field change the dropdown to "Parameterized" and set the field to ": id"
e. Save the SOAP Client

5) Assert that the "name" element remained the same in both responses.

a. Right-click the 'getItemById' SOAP Client and select "Add Output > Response > SOAP Envelope > XML Assertor" then click "Finish"
b. Under the "Configuration" tab click "Add..."
c. Select "Value Assertions > String Comparison Assertion" and click "Next >"
d. Select the "name" element and click "Finish"
e. Change the "Expected Value" dropdown to "Parameterized" and set the field to ": name"
f. Save the XML Assertor

Comments

  • nsfmost2005
    nsfmost2005 Posts: 8

    how do we parametrize WSDL from data source?

  • jakubiak
    jakubiak Posts: 795 admin

    The WSDL field cannot be parameterized from data source or test suite variable. It can only be parameterized from an environment variable.