Steering Webservices

As of Tricentis Tosca 12.2, the Webservice Engine 3.0 is no longer supported. By default, you cannot create WSE TestCases in API Scan.

For information on how to re-enable scanning WSE TestCases in API Scan, see chapter "Web service".

Create REST or SOAP Webservice TestCases and Modules with the Tosca API Scan as described in chapter "Tricentis Tosca API Scan" and chapter "Create TestCases with API Scan".

Alternatively, you can create and steer SOAP or REST Webservices as described in the following sections.

Steering SOAP Webservices

Generally, when steering SOAP Webservices, the following three use cases can occur. The procedure to prepare Modules and TestCases is partly different for each use case. The following sections give an overview of steps to be taken in these different cases.

Based on scanned WSDL files

The easiest case to steer a SOAP Webservice is when the request and response of the various operations are contained in the scanned WSDL file.

  1. Scan the WSDL file as described in chapter "Creating XModules from a WSDL file manually". XModules are created as described in this chapter.

  2. Drag and drop the desired XModule <Operation> on a TestCase. Insert TestCase specific data and check the automatically inserted data (see chapter "Using scanned Webservice Modules").

The TestCase can now be executed.

Using separately scanned XML files as embedded

If separately scanned XML files are used in embedded mode, the following steps must be followed:

  1. The XModules created by scanning XML files must be prepared as described in the chapter "Defining XModules from files as request or response", before they are used as specializations for Request or Response.

  2. The XModule Communicate with Web service must be used directly and adapted manually (see chapter "Using the Module Communicate with Web service").

Loading XML from a file

If request and response are loaded from an XML file, proceed as described in chapter "Adding a request from a file".

Steering REST Webservices

REST unlike SOAP has no predefined message format. Tosca currently supports JSON per default or XML.

Generally, when steering REST Webservices, the following three use cases can occur. The procedure to prepare Modules and TestCases is partly different for each use case. The following sections give an overview on steps to be taken in the different cases.

Loading JSON from a file

With the TBox package, the XModule Communicate with Webservice (REST/JSON) is provided. If this Module is used in a TestCase, the following specializations are already implemented:

  • Webservice request data in JSON Resource (Request)

  • Rest over HTTP (Communicate)

  • Webservice response data in JSON Resource (Response)

To steer a REST Webservice loading JSON from a file, proceed as descibed in chapter "Adding a request from a file" using the XModule Communicate with Webservice (REST/JSON).

Using JSON or XML embedded

When using JSON or XML Modules in embedded mode, the Module Communicate with Web service (REST/JSON) can be used as follows:

  1. Drag and drop the XModule Communicate with Web service (REST/JSON) onto a TestCase.

  2. Delete the specializations of Request and Response.

  3. Set the JSON or XML Modules for request and response as specialization. The JSON or XML Modules must be defined as request or response beforehand (see chapter "Defining XModules from files as request or response").

Loading XML from a file

When using XML loaded from a file, the Module Communicate with Web service (REST/JSON) can be used as follows:

  1. Drag and drop the XModule Communicate with Web service (REST/JSON) onto a TestCase.

  2. Delete the specializations of Request and Response and set the XModules Web service request data in XML Resource and Web service response data in XML Resource as specialization.

  3. Then proceed as as descibed in chapter "Adding a request from a file".

Examples - SOAP

Examples on steering SOAP Webservices can be found in the following chapters:

Examples - REST

A sample of REST examples is provided in this chapter, dealing with the most common HTTP methods.

GET

When using the HTTP method GET, the XTestStepValue Request is not required and thus deleted.

In this example, the HTTP method GET is sent to a Webservice in order to request the file books.json. The file is verified afterwards.

  1. The XModule Communicate with Web service (REST/JSON) is used. The XTestStepValue Request is deleted.

Delete Request

  1. In the XTestStepValue Communicate, the Adress of the file books.json, the Method GET, the Content-Typeapplication/json and the expected Status code name200 OK is filled in.

XTestStepValue Communicate

  1. For the XTestStepValue Response, the XModule of the JSON file is set as specialization. This XModul has to be defined as response beforehand (see chapter "Defining XModules from files as request or response").

  2. For the first item in the the array books, the text of the objects title, author, year and price are verified.

Verify response

POST

When using the HTTP method POST, the XTestStepValue Response is not required and thus deleted. The HTTP method PUT is used in the same way as POST - only differing in the server behavior.

In this example the HTTP method POST is used in order to add an XML file.

  1. The specialization of Request is changed. The XModule of the file books.xsd is set as specialization. This XModul has to be defined as request beforehand (see chapter "Defining XModules from files as request or response").

  2. The data of the file is filled in.

Enter request data

  1. In the XTestStepValue Communicate, the Address where the file is added, the MethodPOST, the Content-Type and the expected Status code name201 Created is filled in.

XTestStepValue Communicate

  1. The XTestStepValue Response is deleted.

Delete XTestStepValue Response

DELETE

When using the HTTP method DELETE, Request and Response are not required and thus deleted.

In this example, the HTTP method DELETE is used in order to delete a file.

  1. The XModule Communicate with Web service (REST/JSON) is used in the TestCase. The XTestStepValues Request and Response are deleted.

Delete Request and Response

  1. In the XTestStepValue Communicate, the Adress of the file that is deleted, the MethodDELETE and the expected Status code name200 OK are filled in.

XTestStepValue Communicate