Recording Virtual Services (New Virtual API Wizard)

Applies to ReadyAPI 3.51, last modified on March 21, 2024

In ReadyAPI, you can create a virtual service (virtual API) by recording HTTP or HTTPS traffic to some existing API. ReadyAPI will create virtual operations from requests and responses it detects during the recording.

You start recording in the New Virtual API wizard or the New Virtual Service dialog. This topic describes the use of the wizard.

In This Topic

Supported Virtual Services

With the wizard, you can record operations for REST virtual services only. To record SOAP services, start recording with the New Virtual Service dialog. To record JDBC virtual services, start with an empty JDBC service.

JMS virtual services cannot be created with recording.

1. Start Recording

  1. From the main menu, select File > New Virtual API:

    Service virtualization with ReadyAPI: Creating a new virtual API

    – or –

    On the Dashboard, click Virtual API in the New Test tile:

    Service virtualization and API testing: Creating a new virtual API

    Click the image to enlarge it.

  2. In the subsequent New Virtual API wizard, click Recorded Traffic > Start:

    Service virtualization and API testing: Creating a new virtual API from recorded traffic

    Click the image to enlarge it.

  3. On the next page, enter the URL of the API, you want to record requests to:

    Service virtualization and API testing: Setting the API URL for traffic recording

    Click the image to enlarge it.

    Note: The recorder uses this value to save operation paths correctly. Suppose that you send a request to http://my-serv/v2/pet/findByTags. If you enter http://my-serv/v2 as the API URL, the recorder will save the operation path as /pet/findByTags. If you enter http://my-serv, the operation path will be recorded as /v2/pet/findByTags.
  4. On the next page, specify the project to which the wizard will add the new virtual API. You can select from the projects opened in your current workspace. To create a new project, select <New Project>:

    Service virtualization and API testing: Select a project for new virtual service

    Click the image to enlarge it.

    Click Finish to continue.

  5. ReadyAPI displays a dialog, where you can select the tool for sending requests:

    Service virtualization and API testing: Selecting a tool for sending requests

    Click the image to enlarge it.

    Depending on the target API, you can choose to open a regular web browser and send requests from there, or you can use some other tool for interaction, for example, cURL or mobile application. The latter approach, for example, helps you record traffic and create a mockup service for an Internet-of-Things API.

2. Send Requests

After you selected the tool for sending a request, ReadyAPI creates a new virtual service of the REST type and automatically runs this service. It also pre-configures the service properties to enable the recording support. We will explain the property values below.

Service virtualization and API testing: Running virtual service for recording

Click the image to enlarge it.

To record traffic, send requests to your live API. The recorder will track requests and responses and will create appropriate virtual operations.

Important: In the requests you send, replace the server name with your service’s address (by default, http://localhost:8080). For example:

A request to the live API: http://my-server.com/v2/pet/findByTags?status=new
Use this for recording: http://localhost:8080/v2/pet/findByTags?status=new

If you selected to record with a browser, you will see that the browser automatically replaces your real API URL with localhost in the address string.

Tip: To record several responses for the same request, simply send the request several times.

3. Stop Recording

  • After you send the needed requests, stop the recording by clicking Stop on the toolbar:

    Service virtualization and API testing: Stopping the recording

    Click the image to enlarge it.

  • We would recommend that you disable routing in your virtual service after the recording. Else, if you run tests against the service, it will route requests and re-record responses:

    Service virtualization and API testing: Disabling request routing

    Click the image to enlarge it.

How Recording Works

The idea behind recording is rather simple: when you send a request, the virtual service redirects it to the API you specified, then receives the response and creates an appropriate operation.

To support this behavior, ReadyAPI assigns the Route and Record Non-Virted Request value to the Route Options property of your virtual service:

Service virtualization and API testing: Service properties pre-configured for recording

Click the image to enlarge it.

The Route Options property sets the functioning mode of a virtual service. The Route and Record Non-Virted Request value means that the service forwards all incoming requests to a real API and creates virtual operations for those requests, for which it does not have virtual operations yet. The real API address is set in the Route to edit field (see the image above). For information on other routing settings, see About Routing.

Notes

  • To record several responses for the same request, simply send this request several times during the recording. You can then configure response settings in the virtual service editor to use conditional responding.

  • If you request the same resource with different parameters, the service will record several operations.

  • Do not forget to disable routing after the recording is over.

See Also

Creating Virtual Services

Highlight search results