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