【发布时间】:2011-03-17 22:49:42
【问题描述】:
我正在尝试编写用于 BizTalk 的基本单向自定义 WCF LOB 适配器。但是,目标系统不一定支持 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]'/>
在我的CustomAdapterOutboundHandler 类中的Execute 方法的实现中,如何检索已在发送端口配置中指定的编码?
/// <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;
}
【问题讨论】: