Checking Returned Values Through a Database

In this scenario, a user executes a an action which returns a response. The goal of this scenario is to validate the response against expected values.

The expected values are stored in a database. The script fetches the expected results from a database and then compares them with the actual response.

The following table shows a typical flow of a Web Service protocol script. You can employ a similar flow for other protocols.

API function
Connect to database
lr_db_connect (in vuser_init section)
Web Service call
web_service_call with Result=<result_param>
Execute an SQL query
Retrieve the expected data
lr_db_getvalue to <param_name>
Validate the data
soa_xml_validate with an XPATH checkpoints.
Disconnect from database
lr_db_disconnect (in vuser_end section)

The following example illustrates a typical validation of data returned by a Web Service call. The validation step compares the actual expected results:

    web_service_call( "StepName=GetAddr_102",
        "SQLQuery=SELECT * FROM Addresses WHERE name = 'abcde' ", 
    soa_xml_validate ("StepName=XmlValidation_1146894916",
    return 0;

For more information, see the Function Reference.

Back to top