1

BizTalk で使用する基本的な一方向のカスタム WCF LOB アダプターを作成しようとしています。ただし、ターゲット システムが Xml メッセージをサポートしているとは限りません。カスタム WCF アダプターを通過するメッセージは XML エンベロープでラップされ、メッセージ本文は次の 4 つの方法のいずれかでエンコードできることを理解しています。

  • 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;
    }
4

1 に答える 1

1

やっとわかった..

次のようなコードが実行されます。

object strvalue;
bool result = Message.Properties.TryGetValue("http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties#OutboundXmlTemplate", out strvalue);
if (result)
{
  XmlDocument xmldoc = new XmlDocument();
  xmldoc.LoadXml(strvalue.ToString());
  string btsencoding = xmldoc.SelectSingleNode("//*[local-name()='bts-msg-body']").Attributes["encoding"].Value;

// do something useful
}
于 2011-05-05T19:22:03.040 に答える