Adding Custom HTTP Headers to messages send via HTTP Adapter

|  Posted: June 6, 2007  |  Categories: BizTalk Server General Technical
Tags: Adapters
You can download the entire article as a PDF document.
Adding Custom HTTP Headers to messages send via HTTP Adapter

There will often be times we need to add some custom HTTP Headers to our outgoing message. The common one we come across is SOAPAction, if you need to communicate with the web services just with HTTP adapter (not using SOAP Adapter).

BizTalk server gives us a context property called UserHttpHeader as part of the HTTP adapter, which can be used to set custom HTTP headers.

The below Orchestration shows an example, how you can take advantage of “UserHttpHeader” property.

biztalk send/receive port

The code inside the “Message Assignment” shape is shown below:

MSG_AUTHOR_OUT = MSG_AUTHOR_IN;
MSG_AUTHOR_OUT(*) = MSG_AUTHOR_IN(*);
MSG_AUTHOR_OUT(HTTP.UserHttpHeaders) = “userName: Saravanarnpassword: hola”;

Important things to note:

  1. You can add multiple headers (ex: userName, password) in a single line as shown in the sample above.
  2. rn” is used to separate multiple headers.
  3. :” is used to separate header and value, you must specify a SPACE after colon.

The content of the output file is shown below

POST /HTTPReceiver/Default.aspx HTTP/1.1
Connection: Keep-Alive
Content-Length: 312
Content-Type: text/xml; charset=utf-16
Expect: 100-continue
Host: localhost:3131
User-Agent: Microsoft (R) BizTalk (R) Server 2006 3.0.1.0
userName: Saravana
password: hola

<?xml version=”1.0″ encoding=”utf-16″?><<stripped content for clarity>>

I used an orchestration sample to demonstrate how you can set UserHttpHeader context property. But like any other BizTalk context property you can set this property in different places like within custom adapter, custom pipeline etc.

Download Full sample code here

Nandri!

Saravana

You can download the entire article as a PDF document.
Adding Custom HTTP Headers to messages send via HTTP Adapter
Author: Saravana Kumar

Saravana Kumar is the Founder and CTO of BizTalk360, an enterprise software that acts as an all-in-one solution for better administration, operation, support and monitoring of Microsoft BizTalk Server environments.

  • Kundan Karma

    Hi Saravana,

    You are true genius!
    This post today helped me a lot.

    Thanks for sharing
    Kundan Karma

One Platform Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

One Platform - Operations, Monitoring and Analytics Software
BizTalk360

microsoft biztalk

Learn more

Over 500 customers across 30+ countries depend on BizTalk360

One Platform - Operations, Monitoring and Analytics Software
ServiceBus360

Azure service bus

Learn more

Start managing your Azure Service Bus namespaces in minutes

Back to Top