USE CASE: DATA INTEGRATION

How to switch logic based on the header of a HTTP payload

David Brown  |  August 12, 2021

http-to-sql

Header based routing to a sql database

We had a request from a customer asking us if they could implement different integration logic depending on the header of a HTTP request.

We built this demo so that others could learn from this example should they also need to implement logic that is based on a value in the header of a HTTP payload.

In this use case we will accept a payload via HTTP, inspect the header of the request and then depending on the value in the header, write the payload to a SQL database.

watch this use case in action

Line by Line: How this "HTTP (header based routing) to SQL" demo works

screenshot-service

  • Routing the request payload to an SQL Database.
    • The RoutingService located at \\code\demo006\services is the service that gets called when a request is made to the /sku REST endpoint.
      • Line 3: Fork x_sku_entity: \ When the service gets called, the request payload and header are passed into this service. It will first check the header value before it decides what to do with the request payload received.
        • Line 4: Case ECOMMERCE \ If the header value received is ECOMMERCE this line gets executed, mapping the request payload received by this service to the SQL service that saves the data in the ECOMMERCE_SKU table.
        • Line 5: Case INVENTORY \ If the header value received is INVENTORY, it will do the same action with line 4, except that it saves the request payload to the INVENTORY_SKU table
        • Line 6: Case $null \ This line is a fallback option if there is no header value provided.
    • If the request payload received by this service does not match the target entity, the request will still be processed, only mapping the properties that are common to both entities.