none
Creating XML message in Orchestration

    Question

  • Hi,

    I want to create a XML message dynamically in Orchestration, for that I have created a message of say msgXMLType of System.Xml.XmlDocument type and a varible varXMLDoc of System.Xml.XmlDocument type.
    Now, here are my queries



    1) I need to create 2 nodes in msgXMLType with name <StoreUse> and <IDT>. How to do this?
    2) after creating this message, I need to assign the values from xPath of a variable from RcvSchema.
    3) I am looping through my detail records and need to assign the values of 2 elements of rcvSchema 'StoreUse' and 'IDT' from each detail while creating a new record each time in msgXML.
    4) After assigning the values I need to loop through the msgXML to check if the value of next coming detail record exists in my msgXML. How can I loop thorugh the msgXML which I created dynamically?

    Here is a sample what I want:

    my rcvSchema values

    StoreNo|StoreUse|IDT|Date
    897      |123        |9    |21-12-2009
    897      |120        |1    |21-12-2009
    897      |121        |2    |21-12-2009
    897      |126        |4    |21-12-2009
    897      |129        |7    |21-12-2009

    now I want the values in msgXML as shown below.

    <Root>
     <Store>
      <StoreUse>123></StoreUse>
      <StoreUse>120></StoreUse>
      <StoreUse>121></StoreUse>
      <StoreUse>126></StoreUse>
      <StoreUse>129></StoreUse>
    </Store>
    <IDT_ID>
      <IDT>9</IDT>
      <IDT>1</IDT>
      <IDT>2</IDT>
      <IDT>4</IDT>
      <IDT>7</IDT>
    </IDT_ID>
    </Root>

    Now 1st Loop will go through the detail record of rcvSchema values and the values will be inserted in msgXML with for loop counter increment.
    2nd loop will exist on msgXML inside of 1st and I have to check the values of StoreUse and IDT which exist presently in first loop detail record. So 2nd loop will run through the msgXML checking for existing values as many as have been inserted matching the first loop counter.

    Please help!
    Monday, December 21, 2009 2:20 PM

Answers

  • Hi

    I have a couple of thoughts about this:
    1. To me this sounds much more like a job for a map. Any reason you are not using that?
    2. If you really need to do all this dynamically without a map, I would write a .NET assembly that you can call from the orchestration that will return the XMLDocument. Whether you end up with an external assembly or doing it inside the orchestration, your question, I think, is more about programming with XML in .NET, which you might seek help for here: http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/threads. Baiscally, you will need an XmlWriter, that can be used roughly like this:
    XmlWriter writer;
    writer.WriteStartElement("Store");
    foreach (whatever)
    {
        writer.WriteElementString("StoreUse", SomeValue);
    }
    writer.WriteEndElement();
    writer.WriteStartElement("IDT_ID");
    foreach (whatever2)
    {
        writer.WriteElementString("IDT", SomeOtherValue);
    }
    writer.WriteEndElement();
    

    Good luck.
    eliasen, representing himself and not the company he works for.
    Three times MVP and three times MCTS in BizTalk.
    Blog: http://blog.eliasen.dk
    Monday, December 21, 2009 7:28 PM