Manipulating HTTP Headers in IBM Integration Bus

No alt text provided for this image

Author: Savio Barros - saviobarr@gmail.com

Introduction

HTTP Headers allow transmission of additional information between http requests and responses, by storing it in fields (name/value pair). HTTP Headers have default fields/values. These default fields accomplish most of requirements, but sometimes it is necessary to manipulate HTTP Headers, by adding new fields or modifying values of existing ones. IBM Integration Bus supports http header manipulation by providing the HTTPHeader node or ESQL. In this post we are gonna visit how to accomplish it in both ways.

1 - HTTP Header manipulation using HTTPHeader node

HTTPHeader node allows the following operations on HTTP Headers:

● Add new fields

● Modify fields

● Remove fields

It can be used to manipulate headers in flows exposed as SOAP, HTTP or REST. The examples below show a HTTP Header before and after.

Before: using Postman to make a http request and debugging our flow. Note that there are no additional fields in message tree:

No alt text provided for this image

In the response, we see default http header fields:

No alt text provided for this image

After: Using HTTPHeaders node, we add a new field called MyHeaderField in the response HTTP Header, and set its value to MyHeaderFieldValue:

No alt text provided for this image

After deploying the changed flow, we make a new request in Postman, and when execution stops at breaking point, examining the message tree, we can see a new field:

No alt text provided for this image

In Postman, the new field appears in the response header:

No alt text provided for this image

NOTE: in this example, we created a new field in the HTTP response header, is possible to create fields in the HTTP request header :

No alt text provided for this image

To delete a header, select Properties/HTTPInput|HTTPResponse and select the radio Delete Header:

No alt text provided for this image

 2 - HTTP Header manipulation using ESQL code

In this example, we remove the HTTPHeader node and insert a Compute node:

No alt text provided for this image

Double click the ChangeHeader compute node to open the ESQL editor, and insert the line below:

No alt text provided for this image

The response in Postman:

No alt text provided for this image

Conclusion: HTTP Header manipulation rarely is necessary, but IIB offers easy and concise methods to manipulate HTTP Headers. This is just an introduction. To learn more about, visit the IIB Knowledge Center:

https://www.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ac60280_.html


To view or add a comment, sign in

More articles by savio barros

  • Mutex in Golang

    Author: Savio Barros - saviobarr@gmail.com Basics One of the most powerful features in Go is its concurrency…

  • Quarkus – creating a project and setting it up

    1. Scope This article shows how to create a simple Quarkus project using CLI, import it into Eclipse, configure Eclipse…

    2 Comments
  • Arrays in Go - Part 1

    Author: Savio Barros - saviobarr@gmail.com “Arrays in Go is a sequence of elements, numbered of a specific length” (Go…

  • Introduction to Go - Part 1: how to install Go

    Author: Savio Barros (savio.barros@certsys.

  • IBM BPM Advanced - Dynamically Invoking destination components with Selectors

    Author: Savio Barros (saviobarr@gmail.com), Business Integration Architect Technical Review: Mike Moreira, Sandro…

    4 Comments
  • Installing and Configuring IBM BPM Advanced

    BEFORE INSTALLING TIP: Avoid trouble when creating DE: if you use hosts that are spread across multiple machines, try…

    2 Comments
  • Leap year algorithm

    October 4, 2015What is Leap Year? Leap Year is a year which has one additional day in February, in order to keep the…

Others also viewed

Explore content categories