Configure Response Dispatch

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

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

Set 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 add.png to add a new rule. This will invoke the Rule Editor.

  4. Set the following values:

    Service virtualization and API testing: Detailed dispatch settings
  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

Publication date: