Run Virtual Service and Send Requests

Now that your project contains a configured virtual service, you can start and test it.

Start a virtual service

You can run virtual services on your computer or on other machines in your network. To run on other machines, you install VirtServer on them (see Running Virtual Services).

In this tutorial, let’s run the virtual service on your computer. To do this, click run.png Run in the service editor:

Service virtualization and API testing: Running a virtual service

Note

It is prohibited to run several web servers or services on the same port. If you already have some other web service or web server working on the port, on which your virtual service is working, the run will fail. Change the service port number and try starting the service again.

Also, if you run a virtual service that uses request routing, you can run only one service at a time in ReadyAPI. You can run multiple virtual services that use request routing on a remote computer that has VirtServer installed.

Create test request

After your virtual service starts, we can send requests to it.

  1. Select the virtual service in the Navigator panel to view its properties, and copy the value of the Virtual service URL field:

    Service virtualization and API testing: Copying the virtual service URL
  2. Expand the API node in the Navigator panel. When you add an operation to your virtual service, ReadyAPI automatically generates an API specification for your virtual service and adds the operation to that specification:

    Service virtualization and API testing: Operations in the Navigator panel
  3. Open the request editor and specify the endpoint your virtual service uses (http://localhost:8088/ in our case):

    Service virtualization and API testing: Setting the endpoint
  4. Now, we need to specify request parameters. To do this, click add.png and enter data in the table. Add the following two parameters:

    Name

    Value

    Type

    response_type

    code

    QUERY

    client_id

    12345

    QUERY

    Here is what the editor looks like now –

    Service virtualization and API testing: Request parameters

Run test request

  1. To simulate a request, click send-request.png in the request editor.

    The service will process the request. You will see the LoginSuccess response contents in the editor:

    Service virtualization and API testing: Running test request
  2. Change the client_id parameter to some other value and run the request again. The virtual service dispatcher will choose the LoginFailed response:

    Service virtualization and API testing: Test results

In the request editor, you can see the request parameters and the response contents, and check whether your virtual service works as expected. You can also see the requests and editors on the Transaction Log page in the virtual service editor:

  • Select your virtual service in the Navigator panel and switch to the Transaction Log page of the virtual service editor.

    Service virtualization and API testing: Transaction Log page
  • Each row on the page corresponds to a transaction, that is, to the request-response pair.

    To view the contents of a request or response, simply select this request or response on the page. You will see the contents on the right (see the image above).

After you send requests and see results, stop the virtual service. To do this, simply click stop.png Stop in the service editor.

Prev Next

See Also

Publication date: