Manipulating HTTP Headers in IBM Integration Bus
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:
In the response, we see default http header fields:
After: Using HTTPHeaders node, we add a new field called MyHeaderField in the response HTTP Header, and set its value to MyHeaderFieldValue:
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:
In Postman, the new field appears in the response header:
NOTE: in this example, we created a new field in the HTTP response header, is possible to create fields in the HTTP request header :
To delete a header, select Properties/HTTPInput|HTTPResponse and select the radio Delete Header:
2 - HTTP Header manipulation using ESQL code
In this example, we remove the HTTPHeader node and insert a Compute node:
Double click the ChangeHeader compute node to open the ESQL editor, and insert the line below:
The response in Postman:
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