Handling multiple responses dynamically in ICS Orchestration:

We are using one REST Web Service for which we will get two different responses based on availability of tables for a given time.

Use case: Get the available tables for a given time.

Request Parameters:
                                       Restaurant ID: 642346,
                                       Time: 10:00
(Along with above parameters some other parameters are required which are common for all requests.)

Response1: For the given time if tables are available, the response is
        "RestaurantId": 642346,
        "AvailableTables": 3

Response2: For the given time if tables are not available, the response will be
        "StatusCode": 3,
        "Status": "Tables are not available for given timeslot."


New Integration -> Orchestration (Give the required details like name etc)

1.      Trigger: In orchestration drag a Sample REST trigger Endpoint -> Provide all required details -> In response tab choose a file which is a combination of multiple response like below

Sample JSON file:

        "RestaurantId": 642346,
        "AvailableTables": 3,
        "StatusCode": 3,
        "Status": "Tables are not available for given timeslot."

Provide above four attributes as a json file in above wizard.

2.      Invoke: Drag a REST invoke endpoint connection and provide the same response file as above.

So as of now two connections were configured in our orchestration, the diagram will be looks like below

3.      Map the request parameters:

4.      Map the response parameters:

5.      Configure Switch action :

In order to use multiple responses in one orchestration we need to write a condition in switch to route the response dynamically.

Switch Condition:

In our scenario the StatusCode attribute value is 3.

So we can use status code as a condition here.

è Drag the statusCode attribute from response attribute.
è Provide the value as 3.


The above condition is used to route the response based on statuscode if the status code is 3 it will go to the first route otherwise it will go to below route.

                                 5.1  Drag a Map from actions for first response:

5.2  Drag a Map from actions for second response:

The final orchestration is shown in below figure


Popular posts from this blog