Sunday, February 4, 2024

Biztalk generic pipeline - convert flat file to xml

 There are number of occasions when we have to flatten the flat file data in the database for the polling based interfaces. For this , Biztalk provide flat file disassembler which works on the flat file schema where we define the field position using the schema node. This is the standard thing right!! . 

This approach provides the xml based on the defined schema and the xml can be fed to a send port which in turn can push the xml to the db. Now , if we look at this approach , there are couple of annoying issues from the schema perspective ,

1) Need to define different schema for different type of flat file.

2) Schema deployment to the multiple servers every time there is change in schema due to the changes in the flat file structure.

 Solution - 

We can create a pipeline which can convert flat file structure to generic xml. This approach can overcome the issues mentioned above. No schema and therefore no schema changes and therefore no deployments.

So , how do we do that !!.

We create a custom pipeline component which has the properties like Delimiter char and field count . we can also have bool property which can be used to decide whether we want to enforce that a particular flat file must have certain number of fields.

This component is quite simple and uses XDocument library to split the delimited content in the xml.