Creating Responses

Applies to ReadyAPI 3.5, last modified on January 19, 2021

Add Responses

To virtualize an API, you need to create responses for virtual requests. You can create multiple responses for one request. The virtual service will use the dispatch settings to select a response for the reply.

To create a response, simply click Add Response for the desired request in the virtual service editor:

Service virtualization and API testing: The Add Response command

Click the image to enlarge it.

Note that, after you create an operation, ReadyAPI creates an empty response for it. Also, if you use the Discovery feature to virtualize your REST or SOAP API, ReadyAPI records all the responses the existing API sends for a request.

Set Response Contents

After adding a response, you need to specify its contents. You do this in the editor on the right. The editor fields and contents depend on the virtual service type: REST, SOAP and JMS services use different response properties:

  • For REST and SOAP services, set the HTTP status code field. It specifies the response code to be returned to clients. The clients use it to determine if the request was successful or not.

    As for the response data, you can enter them into the Edit field:

    Service virtualization and API testing: Configure REST response

    Click the image to enlarge it.

  • For JMS virtual services, you specify the response contents in the Edit fields. Also, check the JMS Destination properties: they specify the JMS session, topic or queue, to which the service will send the response:

    Service virtualization and API testing: Configure JMS response

    Click the image to enlarge it.

  • For JDBC virtual services, you change the response contents in the Result section. Depending on the query, the section contains the table with data or the number of rows mudified.

    Service virtualization and API testing: Configure JDBC response

    Click the image to enlarge it.

For information on specific settings to be made, see topics of the Virtual Service Specifics section. For complete information on response properties, see Reference.

Set Custom Headers

Besides response body data, you can also add custom headers to responses. You do this in the Headers section:

Service virtualization and API testing: Creating custom response headers for virtual services

Click the image to enlarge it.

Custom headers can include virtual service properties and the data source's data (see below).

Use Virtual Service Properties and DataSource Data

You can customize the response data by inserting virtual service properties and the data source's data into them. This will allow you to create responses that have the same structure, but contain different data.

You can include the properties into response contents and headers. You do this by typing expressions that have a syntax like this:

${MockService-service-property-name}

${MockResponse#datasource-property}

For complete information, see Property Expansion in Responses and DataSources in Virtual Services.

See Also

Configuring Virtual Services
Creating Requests (Operations)
Property Expansion in Responses
DataSources in Virtual Services

Highlight search results