3. Configuring Response Dispatch

Applies to ReadyAPI 3.53, last modified on May 15, 2024

The Dispatch Style setting specifies which response a virtual service returns for an incoming request. ReadyAPI offers a number of dispatch strategies for every virtual operation. You can select a dispatch style in the virtual service editor:

Service virtualization and API testing: Dispatch settings

Click the image to enlarge it.

By default, new operations have the Sequence dispatch style. It means that an operation will return responses, which you defined for it, in series. The Query Match and XPath styles let you select a response depending on the request content. The Parameter style will help you customize the response depending on the parameter values of the incoming request. For detailed information on the available dispatch strategies and their properties, see Dispatching Responses.

What we are going to do

Let’s use the Parameter dispatch strategy and implement the following virtual service behavior:

  • If an incoming request has these parameters –

    Parameter Value
    response_type code
    client_id 12345

    – then the virtual service should return the LoginSuccess response.

  • Otherwise, the service should return the LoginFailed response.

Setting dispatch properties

  1. For the Get /login virtual operation, select Parameter from the Dispatch Style drop-down list and click Configure.

  2. Set Default Response to LoginFailed.

  3. Click to add a new rule. This will invoke the Rule Editor.

  4. Set the following values:

    Service virtualization and API testing: Detailed dispatch settings

    Click the image to enlarge it.

  5. Click OK to save the changes.

We have configured the dispatch settings. Now, our virtual service is ready for running and testing.

Prev          Next

See Also

Creating Your First Virtual Service
Response Dispatching

Highlight search results