I'm trying to write a basic One-Way custom WCF LOB Adapter for use in BizTalk. However, the target system does not necessarily supports Xml messages. I understand that messages flowing through a custom WCF adapter are wrapped in an XML envelope and that the message body can be encoding in one of four ways :
- Xml
- String
- BinHex
- Base64
This settings is governed by the configuration of the Outbound WCF message body
property, which accepts an property that looks like the following XML fragment :
<bts-msg-body xmlns='http://www.microsoft.com/schemas/bts2007' encoding='[xml|base64|hex|string]'/>
In the implementation of the Execute
method in my CustomAdapterOutboundHandler
class, how is it possible to retrieve which encoding has been specified on the send port configuration ?
/// <summary>
/// Executes the request message on the target system and returns a response message.
/// If there isn’t a response, this method should return null
/// </summary>
public Message Execute(Message message, TimeSpan timeout)
{
// ISSUE: how to retrieve the message body as binary byte[] / stream / whatever ?
// <bts-msg-body xmlns='http://www.microsoft.com/schemas/bts2007' encoding='[xml|base64|hex|string]'/>
System.Xml.XmlDictionaryReader reader = message.GetReaderAtBodyContents();
return null;
}