我正在尝试编写一个基本的单向自定义 WCF LOB 适配器以在 BizTalk 中使用。但是,目标系统不一定支持 Xml 消息。我了解流经自定义 WCF 适配器的消息被包装在 XML 信封中,并且消息正文可以通过以下四种方式之一进行编码:
- xml
- 细绳
- BinHex
- Base64
此设置由属性的配置控制,该Outbound WCF message body
属性接受类似于以下 XML 片段的属性:
<bts-msg-body xmlns='http://www.microsoft.com/schemas/bts2007' encoding='[xml|base64|hex|string]'/>
Execute
在我的类中方法的实现中CustomAdapterOutboundHandler
,如何检索已在发送端口配置上指定的编码?
/// <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;
}