The Dispatch Style setting specifies which response a virt returns for an incoming request. ReadyAPI offers a number of dispatch strategies for every virtual operation. You can select a dispatch style in the virt 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.
Let’s use the Parameter dispatch strategy and implement the following virt behavior:
If an incoming request has these parameters –
– then the virt should return the LoginSuccess response.
Otherwise, the virt should return the LoginFailed response.
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 virt is ready for running and testing.