Transforming requests and responses

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".

The TBox package includes different XModules for transforming requests before they are sent and received responses before they are processed further.

A request can be modified before being sent via the TestStepValue Transform request and a received response can be modified before being processed further via the TestStepValue Transform response.

Procedure

The following describes the procedure for transforming a request. Transforming a response is done in a similar manner.

  1. Scan the information for Request, Response and Communicate as described in chapter "Creating Webservice TestCases".

  2. Expand the TestStepValue Transform request and select the TestStepValue Request transformation.

  3. Select the ActionMode Select.

  4. In the context menu of the TestStepValue Request transformation, select the option Implement specialization and the required specialization module.

    The specialization modules available for transformations will be described in more detail below.

  5. Add whatever additional information is necessary for the transformation. The required information is specified below for each particular transformation.

Adding or removing SOAP envelope

The Modules Add SOAP envelope and Remove SOAP envelope are used to add an SOAP envelope to a request without an envelope and to then remove the SOAP envelope from a response. These Modules are used when there are requests and responses without an envelope.

The Modules are selected as specialization modules, as described above. In the TestStepValue Transform request (specialization module Add SOAP envelope) the SOAP version to be used must be selected as a Value for the TestStepValue Version. No further steps are necessary for the TestStepValue Transform response (specialization module Remove SOAP envelope).

In this example, an SOAP envelope is added to the request before communicating with the Webservice. This is done by selecting the specialization module Add SOAP envelope for the TestStepValue Request transformation. The value of the attribute Version is set to 1.1. As a result, a SOAP 1.1 Envelope is added.

Transformation - add SOAP envelope

The SOAP envelope is then removed for the response. This is done by selecting the specialization module Remove SOAP envelope for the TestStepValue Response transformation. The SOAP Envelope is thus removed from the response. No further steps are necessary.

Transformation - remove SOAP envelope

Creating or extracting MTOM attachments

The Module Create MTOM request is used to add files to an SOAP message (XML resource), and thus create an MTOM request.

The Module Extract SOAP and attachments from MTOM response is used to extract MTOM attachments from a response, decode them, and save them in a file.

The Modules Create MTOM request and Extract SOAP and attachments from MTOM response must always be used together (SOAP Standard). If only one function is required, both Modules are still used, but no values are entered into the non-required TestStepValue - for example, when only one MTOM response is received.

Create MTOM request

The Module Create MTOM request is used to add one or more files to an SOAP request and thus create an MTOM request.

XModule - create MTOM request

Use in TestStep

Create MTOM request - attributes

Attribute

Value

ActionMode

FromResource

No value is specified.

 

ToResource

No value is specified.

 

Input Files

 

Select

FilePath

Path to the file which is added to the request.

Input

XPath

XPath expression that defines where the file is attached. A link to the attached file is added at the specified position.

Input

The TestStepValue Input Files must be instantiated several times in order to attach several files.

Extract SOAP and attachments from MTOM response

The Module Extract SOAP and attachments from MTOM response is used to extract MTOM attachments from an MTOM response, decode them, and save them in a file.

XModule - extract SOAP and attachments from MTOM response

Use in TestStepValue

Extract SOAP and attachments from MTOM response - attributes

Attribute

Value

ActionMode

FromResource

No value is specified.

 

ToResource

No value is specified.

 

OutputFiles

 

Select

FilePath

Path to the file in which the extracted file is saved.

Input

AttachmentIndex

Index of the saved attachment.

Input

AttachmentCount

Number of attachments. If a value is specified here, the number of attachments is verified.

Input

OverwriteFiles

Indicates whether existing files are overwritten.

Input

In this example, the file signxml.png is attached as an MTOM attachment to the request in the resource MTOMIN. A link to the attachment is added under the node UploadDocument1.

The MTOM attachments are extracted from the response, and the second attachment is decoded and saved in the file output.png. If a file with this name already exists in the specified folder, this file will be overwritten.

The TestStepValue Attachment Count is used to verify whether two files are attached.

The SOAP envelope of the response is saved to the resource MTOMOUT.

Example - MTOM attachments

Extracting SOAP attachments

The Module Extract SOAP and attachments from SwA response can be used to extract and save SOAP attachments of a response. The procedure is similar to the Module Extract SOAP and attachments from MTOM response.

Validating requests or responses against a WSDL file

The Modules Validate response against WSDL and Validate request against WSDL are used to verify the validity of a request or a response received. The two Modules are structured in the same way.

Module Validate request against WSDL

The TestStepValue WsdlFileLocation specifies the path or the URI of the WSDL file against which the response or request is validated. All other TestStepValues are not defined.

If an error occurs during validation, this will be shown in the respective ExecutionEntry.

In this example, the received response is verified against the file CalculatorService.wsdl.

Example - Validate response against WSDL

Saving requests and responses

The Modules Save Request and Save Response are used to save a request or a received response. The two Modules are structured in the same way.

Module Save Request

The TestStepValue Filepath specifies the path and file name of the file the request or response is saved in. The path is created if necessary. All other TestStepValues are not defined.

In this example, the request is saved in the file Test1.xml in the directory D:\Requests.

Example - Save Request