Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

A message that is outside a Construct Message shape may not update in BizTalk Server 2004


View products that this article applies to.

Introduction

In Microsoft BizTalk Server 2004, if a schedule tries to assign an XML document to a message that is outside a Construct Message shape, the XML representation will be updated. However, the underlying message object will not be updated.

For example, a schedule receives a message that is named Message_1 in a Receive shape. The message has a variable that is named xmlDoc of type XmlDocument and has the following code in an Expression shape:
  xmlDoc = Message_1;

  // The following function that is in a referenced assembly modifies the XmlDocument.
  DoModifications(xmlDoc);

  Message_1 = xmlDoc;
Then, any subsequent reference to the XML representation of the Message_1 message returns the modified XmlDocument. However, references to the message itself will return the original data.

For example, a subsequent Expression shape contains the following code:
  xmlDoc = Message_1;
  xmlDoc.Save(@"C:\Temp\message1.xml");
In this example, the saved file would contain the modified document. However, if you then add a Send shape to the schedule to send the Message_1 message, the message that is sent would be the original, unmodified message.

↑ Back to the top


More information

Messages that are inside a BizTalk Server-based server are immutable. They cannot be modified as soon as they have been constructed. The initialization of a message and all modification to a message should occur in a Construct Message shape for the message. The XML representation for the message can still be retrieved and manipulated outside the Construct Message shape. However, the underlying message representation itself will not be updated with any changes to this XML representation.

To update a message, a schedule should retrieve the original message, modify the data, and then assign the modified data to a new message that is inside a Construct Message shape for the new message. In the following example, a schedule has messages that are named Message_1 and Message_2. The schedule also has a variable that is named xmlDoc of type XmlDocument. To update the Message_1 message, follow these steps:
  1. Drop a Construct Message shape on the design surface that is under the shape where the Message_1 message is assigned.
  2. Set the Messages Constructed property of the Construct Message shape to Message_2.
  3. Add a Message Assignment shape inside the Construct Message shape.
  4. Set the Expression property of the Message Assignment shape to code that is similar to the following:
    xmlDoc = Message_1;
    
    // The document should be cloned so the XML document for the Message_1 message
    // is no longer pointed to the following:
    xmlDoc = (System.Xml.XmlDocument)(xmlDoc.Clone());
    
    // In a referenced assembly, this function modifies the XmlDocument.
    DoModifications(xmlDoc);
    
    // Assign the updated document to the Message_2 message.
    Message_2 = xmlDoc;
    The orchestration now contains the original message (Message_1) and an updated version of the message (Message_2).

↑ Back to the top


References

For more information, see the "Constructing Messages" topic in the BizTalk Server 2004 Help.

↑ Back to the top


Keywords: KB867803, kbbtsorchestration, kbinfo

↑ Back to the top

Article Info
Article ID : 867803
Revision : 4
Created on : 1/11/2005
Published on : 1/11/2005
Exists online : False
Views : 337