You use the Parameter dispatch strategy to select a response depending on parameters of the incoming request.
The Parameter dispatch type is available for REST virtual services only.
You can check values of the Query, Path and Header parameters.
In the virtual service editor, select the Parameter dispatch strategy.
Click to create a rule – a set of conditions for selecting this or that response. This will invoke the Rule Editor dialog.
In the dialog:
Specify the parameter type (Query, Path or Header), parameter name, comparison condition and expected value.
Click to add more conditions (they will be combined with
In the Send Response field, specify the response that the virtual service will return if the entire condition evaluates to true.
You can create multiple rules if needed. In this case, you will enable your service to return different responses for different parameter values.
In the Default Response box, select the response that the virtual service will return if no match is found.
There is no need to save the changes, ReadyAPI does this automatically. If the virtual service is running on your computer, ReadyAPI applies changes on-the-fly.
Every time the virtual service receives a request, it iterates through the list of rules (from the top to the bottom).
For each rule, it extracts values from the request and compares these values against the expected values:
If the comparison result evaluates to true, the virtual service returns the response specified by the Send Response setting of the rule.
If the comparison result is
false, the virtual service continues with the next rule.
If no matches were found, the virtual service returns the response that is set by Default Response.
The virtual service iterates through the rules in their order in the list. To change the order, select the needed match and click or on the list toolbar.
You can analyze the following parameter types:
Query parameters that are located in the request URL after the question mark, for example,
Path parameters are part of the request URL path, for example
http://localhost:8080/v2/orders/1234/details?page=2. Path parameters are also known as TEMPLATE parameters.
The comparison conditions include Match (regexp). It enables you to compare parameter values with a regular expression. For information on the regular expression syntax, see the documentation of the Java Pattern class.
To edit a rule, simply double-click the rule or select it on the list and click on the list toolar.
To delete a rule, select it on the list and click on the list toolbar.