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:

  1. Create an Excel Spreadsheet with 3 sheets (named keywords, books, and authors).
  2. 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.)
  3. 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.
  4. 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:

  1. Create a new .pva called ArrayDataSource.pva.
  2. Add an Excel Data Source that points to the Excel spreadsheet created in previous steps. Select keywords as the sheet.
  3. Create a new Message Responder.
  4. Set the Message Responder’s WSDL URL to http://soatest.parasoft.com/store-01.wsdl
  5. Set up the Form Input as follows:
    1. Under authors, clear Nill, then click Edit.
    2. Select Fixed, click Insert, then click Modify.
    3. 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.

  • No labels