Ehbit ninja's blog

Our IT ninja's blog about their professional experiences with IT technologies

BTS 2009: Remove Byte Order Mark from messages

Some of our recipients where complaining that they received a ‘?’ in front of the messages we send with BizTalk.
Now, when we view the messages we send to them from the tracked messages, nothing seems to be wrong at first.
As you can see in the below image, the sent message just starts with “<?xml version=”1.0″ encoding=”utf-8″?>” like it should be.

When you look at the same message in the binary mode however, you’ll see that there are several extra characters added in front of the actual message. These extra characters are called Byte Order Marks (BOM). These characters indicate which of the several unicode representations the text is encoded in. In my case, the message is encoded in UTF-8.
For UTF-8 the BOM is “
EF BB BF” (in hexadecimal), or “” (in ISO-8859-1), like shown in the below picture.

Although there’s actually nothing wrong with the sent message, some client applications might have a problem reading your message.

I’ll show you how easy it is to remove these extra characters. The solution for this problem is to just correctly configure your send port. I’m not sure of the older BizTalk versions, but in BizTalk 2009 there is a setting on the XML Assembler component called ‘PreserveBOM’. When you change this setting to False, the Byte Order Mark characters will be omitted in the sent message.

When I now reprocess the same message with this setting, the resulting message will be without a BOM. The picture shows that, even in binary view, the message starts with “<?xml version=”1.0″ encoding=”utf-8″?>“.