Search code examples
xmlsoapbiztalkflat-filebiztalk-orchestrations

Split XML Message into different Flat Files from Orchestration Send


I have a sales order orchestration that sends order messages to a SOAP service. The message contains the order header elements as well as a repeating set of order line items. Example:

<Order>
   <Customer>cust123</Customer>
   <Foo>bar</Foo>
   <OrderLines>
      <Line>
         <ItemSku>123134</ItemSku>
         <Quantity>5</Quantity>
      </Line>
      <Line>
         <ItemSku>56789</ItemSku>
         <Quantity>8</Quantity>
      </Line>
   </OrderLines>
</Order>

I need to introduce a "backup plan" for when the SOAP call fails (whatever the reason may be, e.g. network issues, etc.). I've been asked to take the XML message and convert into a set of flat files (pipe delimited) that represent the order header and order lines, and then send the file to a share which will be swept on a schedule by another process that imports into the same backend system as the SOAP service.

In other words, I need to shred/split the XML up into separate files, since one file is used for the order header, and another is used for the order line items. Note that my actual scenario has other files that are repeating nodes in the order as well but the scenario is exactly as the order line items, so I've kept it simple here.

I've seen a lot of posts talking about debatching, etc, but none of them seem to fit the scenario described above.

What is the best way to accomplish this in BizTalk 2013 R2? Can it be something done at the Send Port, or does this involve custom coding? Please provide steps, and also if possible a link to any related articles resources. Thanks!


Solution

  • It can be done at the send port level.

    Have two new ports subscribing to the message.

    Have one with a map that maps to your flat file header schema and a pipeline to assemble the header flat file

    Have the second port that maps the order lines to your details order lines flat file schema and a pipeline to assemble the details flat file.

    Then, it is just a matter of publishing the message to the message box when the SOAP one fails. This you would probably have to do in an Orchestration with a decision shape.