表示为 XSD 架构的消息

XSD 消息类型的模板 XML 实例在设计时定义,然后存储在磁盘上。 在运行时,.NET 组件从磁盘中选取 XML 并将其作为 XmlDocument 返回。 业务流程代码可以将此 XmlDocument 结果分配给业务流程中声明的消息实例。

消息分配形状有一行代码:

MsgOut = CreateMsgHelper.Helper.GetXmlDocumentTemplate();  

创建 XmlDocument 的帮助程序组件有一个静态方法:

private static XmlDocument _template = null;  
private static object _sync = new object();  
private static String LOCATION = @"C:\MyTemplateLocation\MyMsgTemplate.xml";  
  
public static XmlDocument GetXmlDocumentTemplate()  
{  
   XmlDocument doc = _template;  
   if (doc == null)  
   {  
      // Load the doc template from disk.  
      doc = new XmlDocument();  
      XmlTextReader reader = new XmlTextReader(LOCATION);  
      doc.Load(reader);  
  
      // Synchronize assignment to _template.  
      lock (_sync)  
      {  
         XmlDocument doc2 = _template;  
         if (doc2 == null)  
         {  
            _template = doc;  
         }  
         else  
         {  
            // Another thread beat us to it.  
            doc = doc2;  
         }  
      }  
   }  
  
   // Need to explicitly create a clone so that we are not  
   // referencing the same object statically held by this class.  
   doc = (XmlDocument) doc.CloneNode(true);  
   return doc;  
}  

另请参阅

表示为 .NET 类的消息
表示为 XLANGMessage 的消息
在用户代码中构造消息