none
Message Construction In Construct Shape RRS feed

  • Question

  • Hi All,

    I am getting a MessageIn and in expression shape I am trying to construct the MessageOut as below :

    But at run time, I am getting the error message:

     A failure occurred while evaluating the distinguished field Name against the message part data. The message part data does not contain at least one of the nodes.

    But when I made the message through map by putting some default values then there is no error.

    What is the reason behind it ?


    Thanks

    Friday, July 8, 2016 1:01 PM

Answers

  • Hi Hari,

    The evaluation of a distinguished field requires the element to exist in the xml before you assign a value to it.

    You can either assign a default value or select "<empty>" on the Value property of the destination schema in the map.

    Alternatively, You can generate the instance of the MessageOut schema and assign it to the message. How to Generate Instance Messages

    xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml(@"generated instance of Messageout schema");
    
    MessageOut = xmlDoc;

     

    Rachit Sikroria (Microsoft Azure MVP)

    Friday, July 8, 2016 1:31 PM
    Moderator
  • Hi Hari

    Best approach in your case is to use the map - it's best to avoid creating orch messages from hard-coded strings. Reason why your code is failing is as follows-

    You are assigning an empty XmlDocument to MessageOut.

    So, when you are accessing the Name and Company properties on MessageOut, they do not exist as those elements were not present in the XmlDocument.

    You have to first load at least a template XML in the XmlDocument, and then assign the XmlDocument to MessageOut.

    So,

    varXdoc = new System.Xml.XmlDocument(); //declare varXdoc as an Orchestration variable of type System.Xml.XmlDocument

    varXdoc.LoadXml("your XML string");

    MessageOut = varXdoc;

    See the example here -

    varXMLDoc.LoadXml(@"<ns0:SomeXML><AnElementToPopulate></AnElementToPopulate></SomeXML>");  
    msgYourMessage = varXMLDom;


    Thanks Arindam




    Friday, July 8, 2016 1:31 PM
    Moderator
  • It's very simple, the Xml Node (Element or Attribute) must already exist in the instance for a Distinguished Field to work.  It will not create the node.

    If you are trying to create a completely new message, the best way is with a Map.

    • Marked as answer by Shivay_ Monday, July 11, 2016 10:43 AM
    Friday, July 8, 2016 3:34 PM
    Moderator

All replies

  • Hi Hari,

    The evaluation of a distinguished field requires the element to exist in the xml before you assign a value to it.

    You can either assign a default value or select "<empty>" on the Value property of the destination schema in the map.

    Alternatively, You can generate the instance of the MessageOut schema and assign it to the message. How to Generate Instance Messages

    xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml(@"generated instance of Messageout schema");
    
    MessageOut = xmlDoc;

     

    Rachit Sikroria (Microsoft Azure MVP)

    Friday, July 8, 2016 1:31 PM
    Moderator
  • Hi Hari

    Best approach in your case is to use the map - it's best to avoid creating orch messages from hard-coded strings. Reason why your code is failing is as follows-

    You are assigning an empty XmlDocument to MessageOut.

    So, when you are accessing the Name and Company properties on MessageOut, they do not exist as those elements were not present in the XmlDocument.

    You have to first load at least a template XML in the XmlDocument, and then assign the XmlDocument to MessageOut.

    So,

    varXdoc = new System.Xml.XmlDocument(); //declare varXdoc as an Orchestration variable of type System.Xml.XmlDocument

    varXdoc.LoadXml("your XML string");

    MessageOut = varXdoc;

    See the example here -

    varXMLDoc.LoadXml(@"<ns0:SomeXML><AnElementToPopulate></AnElementToPopulate></SomeXML>");  
    msgYourMessage = varXMLDom;


    Thanks Arindam




    Friday, July 8, 2016 1:31 PM
    Moderator
  • It's very simple, the Xml Node (Element or Attribute) must already exist in the instance for a Distinguished Field to work.  It will not create the node.

    If you are trying to create a completely new message, the best way is with a Map.

    • Marked as answer by Shivay_ Monday, July 11, 2016 10:43 AM
    Friday, July 8, 2016 3:34 PM
    Moderator