A recent question in Stephen W. Thomas' excellent BizTalkGurus forums asked about how to control the value the HTTP send-side adapter in BizTalk Server 2006 sends on HTTP requests. After a little investigation through the adapter code (which lives in the Microsoft.Biztalk.HttpTransport.dll assembly), here's my guess of what goes on:

When the adapter is going to send the message, it gets the value for the Content-Type header from one of theses two locations:

  • If the body part of the message has the ContentType property set (IBaseMessagePart.ContentType), then it is considered
  • If the send port configuration has the Content Type property set, then this value overrides the previous value.

However, that's not all that is considered. As it turns out, the adapter explicitly considers text content types (i.e. "text/*" MIME types). If the content type is a text type, then the adapter will append the encoding of the message to the content type, like this:

Content-Type: text/xml; charset=utf-8

If the content type is not a text type, then it leaves it alone.

If you don't want the charset to be appended to the Content-Type header for any reason, it appears there might be a way around it: The value for the charset is extracted from the Charset property of the body part of the message, but the Content-Type header is only modified if this property contains a non-null, non-empty value.

It would appear possible to work around this then by simply ensuring the Charset property is empty by the time the adapter gets hold of the message; using a custom pipeline component in the send pipeline would seem a good way of accomplishing this.

Technorati tags: , ,

Tomas Restrepo

Software developer located in Colombia.