Share this page

# Check 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.

Step | 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 | lr_db_executeSQLStatement
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)

For more information, see the Function Reference.

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

    Action()
    {
        web_service_call( "StepName=GetAddr_102",
            "SOAPMethod=AddrBook|AddrBookSoapPort|GetAddr",
            "ResponseParam=response",
            "Service=AddrBook",
            "ExpectedResponse=SoapResult",
            "Snapshot=t1227172583.inf",
            BEGIN_ARGUMENTS,
            "Name=abcde",
            END_ARGUMENTS,
            BEGIN_RESULT,
            END_RESULT,
            LAST);
        lr_db_executeSQLStatement("StepName=MyStep",
            "ConnectionName=MyConnection",
            "SQLQuery=SELECT * FROM Addresses WHERE name = 'abcde' ",
            "DatasetName=ds1",
            LAST);
        lr_db_getvalue("StepName=MyStep",
            "DatasetName=ds1",
            "Column=Name",
            "Row=current",
            "OutParam=CustomerName",
            LAST);
        soa_xml_validate ("StepName=XmlValidation_1146894916",
            "Snapshot=t623713af7a594db2b5fef43da68ad59d.inf",
            "XML={GetAddrAllArgsParam}",
            "StopOnValidationError=0",
            BEGIN_CHECKPOINTS,
                CHECKPOINT,"XPATH=/*[local-name(.)='GetAddr'][1]/*[local-name(.)='Result'][1]/*[local-name(.)='name'][1]","Value_Equals={CustomerName}",
            END_CHECKPOINTS,
            LAST);
        return 0;
    }

Back to top

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 25.1-25.3 All View Local Help Center View Online Help Center Version: