SOAtest provides flexible fixed length message format support. Since many different fixed length formats exist (and there is no single standard), Parasoft SOAtest is easily configured to recognize any fixed length message format that the organization works with. This enables you to take advantage of SOAtest's rich interface for message configuration, sending, and validation when working with very specialized message types.

In order to configure and validate fixed length messages in SOAtest, you need to perform the following one-time configuration:

  1. Define a data model that describes your fixed length data format.
  2. Register the data model so that SOAtest can use it in the Fixed Length Client (and other applicable tools).

At this point, you can use the data model in the Fixed Length Client, Fixed Length Call Back Tool, and XML Converter. You can configure the message in the Fixed Length Client and validations in outputs of the Fixed Length Client.

Creating a Fixed Length Data Model

First, we need to understand the message format for which we are going to create a data model. Consider a message where each record is on a different line and simply contains two fields: one for last name and one for first name.  Each field is 10 characters long, is right-aligned, and is padded by spaces.

     Smith    John
       Doe    Jane

To create a fixed length data model for this format:

  1. Create a new empty .tst file as follows:
    1. Choose File> New> Project.
    2. Select SOAtest> Empty Project, then click Next.
    3. Enter a project name (FixedLength), then click Finish.
  2. Create a new Data Model Definition file as follows:
    1. Go to File> New> Data Model Definition File.
    2. Enter Names as the file name, and choose /FixedLength as the location.



    3. Click Finish. The Data Model editor will open.
    4. Enter Names in the Name field, and First and Last Name in the Description field.



  3. Expand the General section and specify the following:
    • Name - people
    • Record name - person
    • Record separator - {platform newline}



  4. Select the Components row, then click the Add button (at the bottom of the editor) twice to add two fields to the data model.



  5. Expand the first field and specify the following:
    • Name - LastName
    • Alignment - right
  6. Expand the second field and specify the following:
    • Name - FirstName
    • Alignment - right



  7. Save the Data Model editor.
  8. Click the Register data model directory link in the top right corner of the editor. This registers the data model that we just created with SOAtest. The model is now available to the appropriate tools.

Creating a New Fixed Length Client

To create a new Fixed Length Client 

  1. Find the FixedLength.tst file that you created in the previous exercise.
  2. Create a new Fixed Length Client as follows:
    1. Right-click the test suite node, then choose Add New> Test.
    2. Select Fixed Length Client, then click Finish.



  3. Select the data model that we just created by choosing Names: First and Last Name in the Message type combo box.



  4. In the Request tab, ensure that Input Mode is set to Form Input.
  5. Modify the automatically-generated person element to use Smith as the last name and John as the first name.



  6. Add a second person element by selecting the people element, then clicking the Insert button below the table.



    Select the new person element, then enter Doe as the last name and Jane as the first name.



  7. In the Transport tab, enter http://localhost:8080/parabank/echo.jsp  in the Router Endpoint field.



  8. Save the editor.
  9. Run the test.
  10. Open the Traffic Viewer, and validate that the sent content looks like the sample message shown at the start of this tutorial.

Extending the Fixed Length Data Model with a Variable Number of Repeating Segments

Now let's assume that for each person, we want to specify a variable number of pets owned by that person. We will start with the data format we used above, but for each record we will add the following:

  • A number field that specifies the number of pets that is 2 characters long, padded with 0.
  • A variable number of sections, where each section contains the type of pet and the name of the pet. The number of sections is equivalent to the number in the field that specifies the number of pets. The field for type of pet is 5 characters long, right-aligned, and the field for the name of pet is 10 characters long, right-aligned.

Here is an example of such data:

     Smith    John00
       Doe    Jane02    Cat   Fluffy  Dog   Spot

Let's start with our existing data model, and extend it to make a new data model:

  1. Create a new data model file as follows:
    1. In the Navigator view, open the FixedLength project.
    2. Right-click the project and choose Refresh to ensure that the view is up to date.
    3. Right-click the Names.datamodel file, and choose Copy.



    4. Paste it into the FixedLength project.
    5. When the new name dialog comes up, enter NamesAndPets.datamodel.



  2. Double-click the new NamesAndPets.datamodel file that is in the FixedLength project.
  3. Enter Names and Pets for the name and remove the description.
  4. Select Components and click Add. This adds a new field.
  5. Change Field to Section, then click Add again. This adds a new section.





  6. For the newly-added (third) field in the top-level section, expand the node for the field and specify the following:
    • Name - NumberOfPets
    • Type - integer
    • Length - 2
    • Alignment - right
    • Padding - 0



  7. For the new section, expand the General node and specify the following:
    • Name - pets
    • Recordname - pet
    • Criteriafornextrecord - xpath
    • XPath - count($section/*) < $section/../NumberOfPets
  8. Select the Components node in the new section, ensure Field is selected, and click Add twice.

  9. Edit the components as follows:
    1. Select the Components node in the new section, then click Edit in Table.



    2. In row 1, specify PetType for Name, 5 for Length, and right for Alignment.
    3. In row 2, specify PetName for Name and right for Alignment.



    4. Click Returnto Full Data Model.
    5. Save the editor.
  10. Add a new Fixed Length Client to the Test Suite of the FixedLength.tst file and select Names and Pets: as the Message type.

  11. Enter the first person’s information as follows:
    1. In the Request tab, select the people element.
    2. Modify the default values as follows:
      • LastName - Smith
      • FirstName - John
      • NumberOfPets - 0



    3. Delete the pets element.

  12. Enter the second person’s information as follows:
    1. Add a second person element by selecting the people element, then clicking the Insert button below the table.
    2. Enter the following values:
      • LastName - Doe
      • FirstName - Jane
      • NumberOfPets - 2



    3. Right-click the pets node for the second person, choose Insert Multiple, specify 2 for the Count, then click OK.
    4. For the first pet, specify the following:
      • PetType - Cat
      • PetName - Fluffy
    5. For the second pet, specify the following:
      • PetType - Dog
      • PetName - Spot

  13. In the Transport tab, set the RouterEndpoint to http://localhost:8080/parabank/echo.jsp.
  14. Save the tool.
  15. Run the test.
  16. Open the Traffic Viewer, and validate that the content that was sent appears like the example data we are modeling.

The .tst file corresponding to these exercises can be found at <SOAtest install dir>/examples/tests/FixedLength.tst.

  • No labels