Applies to ReadyAPI 2.7, last modified on June 25, 2019

About

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.

Setting Up Properties

  1. In the virtual service editor, select the Parameter dispatch strategy.

  2. Click to create a rule – a set of conditions for selecting this or that response. This will invoke the Rule Editor dialog.

  3. 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 AND).

    • In the Send Response field, specify the response that the virtual service will return if the entire condition evaluates to true.

    Service virtualization and API testing: Properties of the Parameter dispatch strategy

    Click the image to enlarge it.

    You can create multiple rules if needed. In this case, you will enable your service to return different responses for different parameter values.

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

How It Works

  1. Every time the virtual service receives a request, it iterates through the list of rules (from the top to the bottom).

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

  3. If no matches were found, the virtual service returns the response that is set by Default Response.

Notes

  • 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, http://localhost:8080?username=Login&password=Login123.

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

    • Header parameters are part of the request header. You can view request headers on the Transaction Log page of the virtual service editor, or in the request editor in SoapUI.

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

See Also

Response Dispatching

Highlight search results