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:
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
-
For the Get /login virtual operation, select Parameter from the Dispatch Style drop-down list and click Configure.
-
Set Default Response to LoginFailed.
-
Click to add a new rule. This will invoke the Rule Editor.
-
Set the following values:
-
Click OK to save the changes.
We have configured the dispatch settings. Now, our virtual service is ready for running and testing.