Web Service Call to a Database
CloudTest provides both SOAP and REST methods to call a database using whatever API is provided. In the following example, we will use a SOAP service to get name from a MySQL database.
- Create a SOAP web service that extracts data from a database.
- Identify the URL to the SOAP service’s WSDL file.This example uses MySQL as the source database. For example, a WSDL that extracts data from MySQL.
Create a CloudTest SOAP target pointing
at this new SOAP web service. See Create a New Target in Target for instructions.For example:
- Create a CloudTest test clip that uses this new target. See Creating a New Clip for instructions.The example test clip will query data from a MySQL database using select statements in the executeQuery operation of the newly created target.
- With the new test clip open, double-click the MySQL target (in the lower-left pane of the Clip Editor) to add it to the “Included Targets” list.
- Double-click the
executeQueryoperation (in the lower-right pane of the Clip Editor) to add an empty SOAP message to the test clip.
- Double-click Message 1 to open its properties in the lower panel.
- Edit the Input. , the SQL being run will be:
select FirstName, LastName from Contacts where id='1'In this sample, we are extracting one record at a time.
- Click Play in the Message Editor panel. The single SOAP request is sent to the destination server.
- The XML request sent is shown in the lower-left pane of the test clip editor and the results of the query will be shown in the lower-right pane of the test clip editor. The data returned by this query can now be used in subsequent steps in the test.
- Click in a field with the data you want to use (the field with “Aaron” is selected in the image to the right).Click the Properties icon on the right to access the Property Chooser dialog box.
- Assign the data that comes back in this query to the selected Property. In this case, a global property named “Contact Data/First Name” has been selected as the property to store this data.
- Repeat this process for each data element you want stored in a property. When you want to use this property in a test message, you use it like any other property. In an input field, simply click the white properties icon, select the property you want included in your input, and then click OK.
What you should see
Note: As usual, run your tests in a test composition for full playback of your test suite.