Virtualize also allows you to map hierarchical data structure in data sources.
For example, suppose that you are creating a Message Responder for a search operation as part of a Bookstore service. Each book returned has a complex XML structure, and a varying number of books may be returned (depending on the search criteria). To support this, we need an “Array Data Source” that can be used to construct the dynamic hierarchical response.
Setting up the Data Source
You could setup the data source as follows:
- Create an Excel Spreadsheet with 3 sheets (named keywords, books, and authors).
- Fill out the keywords sheet as follows.
Notice the books dsref* column. This is how we denote that the book keywords will be from the books sheet. (dsref* denotes Data Source REFerence.) - Fill out the books sheet.
Notice the authors dsref* column again. Notice also the ParentIndex column. The value of the ParentIndex column indicates which keyword the book is related to. For example, both Java books listed in this sheet have the Java keyword. - Fill out the authors sheet.
Notice again the ParentIndex column. Notice that both Harvey M. Deitel and Paul J. Deitel have the same ParentIndex because they are co-authors of How to Program in Java (4th Edition). David Flanagan will be associated with the book that he authored: Java in a Nutshell, Fourth Edition.
Parameterizing Form Input
Next, let’s explore how to use these correlations in the XML. To specify the author component of a response, we’ll parameterize the form input as follows:
- Create a new .pva called
ArrayDataSource.pva
. - Add an Excel Data Source that points to the Excel spreadsheet created in previous steps. Select keywords as the sheet.
- Create a new Message Responder.
- Set the Message Responder’s WSDL URL to http://soatest.parasoft.com/store-01.wsdl
- Set up the Form Input as follows:
- Under authors, clear Nill, then click Edit.
- Select Fixed, click Insert, then click Modify.
- Select Parameterized and books: authors:author.
You would then continue configuring the response in this manner to construct the dynamic hierarchical response you want used.