BizTalk Server Orchestration – message has not been initialized in construct statement

BizTalk Server Orchestration – message has not been initialized in construct statement

This may sound very basic…but…

When using the MessageAssignment orchestration shape, if the message you are using has not been instantiated by a map or a port then you must manually instantiate the message:

Message_Type = new System.Xml.XmlDocument();

//Now that the message has been instantiated it can be used.

Message_Type.[PropertyName] = “Property Value”;

Advertisement

10 thoughts on “BizTalk Server Orchestration – message has not been initialized in construct statement

    • The Transform shape can only be used to call a map. You cannot technically assign values to a message in an Expression shape. It can only be done within a Message Assignment shape. I have seen use of the construct {} statement used in an Expression shape. But, I believe it is clearer in an Orchestration to always use the Message Assignment shape for this purpose. I believe the resultant XLang is the same as using the construct {} statement within an Expression shape.

      This link may be helpful to you…
      http://geekswithblogs.net/michaelstephenson/archive/2006/09/26/92363.aspx

  1. Hi Jglisson

    I have construct the message as you but I get this error
    “Inner exception: A failure occurred while evaluating the distinguished field FileName against the message part data. The message part data does not contain at least one of the nodes specified by the XPath expression (listed below) that corresponds to the distinguished field. The cause for this error may be that the message part data has not been initialized or that the message part data does not conform to the message part schema. Ensure that the message part data is initialized correctly. XPath expression: /*[local-name()=’FileContent’ and namespace-uri()=’http://SaveFileNameToDB.Schemas.FileContent’]/*[local-name()=’FileName’ and namespace-uri()=”]”

    below is code in assignment shape:
    MsgFileContent = new System.Xml.XmlDocument();
    MsgFileContent.FileName = MsgPO(FILE.ReceivedFileName);

    with:
    MsgFileContent is the message created on FileContent schema.
    MsgFileContent.FileName with FileName is the element of filecontent schema

    I think this cause, the MsgFileContent is not xml document type.

    • In this case you will have to actually populate the message with stubbed out XML before you can assign values to it. To do this, you will need a variable of XmlDocument.

      Go to your schema, generate an instance, and copy/paste that into your assign shape as follows.

      varXml = new System.Xml.XmlDocument();
      varXml.LoadXml(@”[paste your xml here]”);

      MsgFileContent = varXml;
      MsgFileContent.FileName = MsgPO(FILE.ReceivedFileName);

      That should get you moving along.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s