Powered By Blogger

Sunday, August 31, 2014

Creating a flat file schema through a wizard in biztalk


Hi there,



It has been a way long since I wrote my last blog. These days i'm working on a new technology named biztalk which according to me has so far been an interesting endeavour in my tryst with biztalk programing :P . Biztalk is one of the widely used integration tool available in the market which supports extensive B2B & EAI integration developed by microsoft. But I'm not writing this blog to explain what biztalk is and what it does. Here is the link to the brief introduction of biztalk --msdn- BizTalk Introduction .
Rather, i'm here to share the inbuilt capabilities of biztalk artifacts which form the backbone of biztalk runtime architecture i.e adapters,pipelines,orchestration,schemas and maps . It would be impossible for me to briefly introduce all the artifacts in a blog and therefore i decided to go with oneartifact/blog :) ....

Schema is one of the important part of biztalk architecture which i will be discussing here. Basically, a schema is something which creates the structure of a file and that file could be anything ranging from xml to flat files.The extension for schemas in biztalk or any other tool is .xsd (XML Schema Definition). The work of schemas is to define the structure of the message it receives, based on which we can create an instance of the generated xsd file into the format we want. Biztalk supports following type  schemas : -

1.XML schema
2.Flat file schema
3.Envelope schema
4.Property schema

For a biztalk beginner, XML schema and Flat file schema should be of concern so as to grasp the logic behind these two schemas so that we meet with minimum problems while facing complex types of schemas.
I will start with flat file schema and in this whole process would be dicussing in brief flat file schemas.
A flat file is a file which consists of records with no structured relationship and stored data in a plain text file.
Flat file are of two types:-

1. Delimited flat files - Example - 1,Saurav,SoftwareEngineer,sauravsuman007@gmail.com

---  In delimited flat file schema the elements of a record are identified after a delimiter like (,) etc.

2. Positional flat files - Example - 1 Saurav SoftwareEngineer sauravsuman007@gmail.com

--- In positional flat file schema the elements of a record are separated by space and are of fixed length

Creating Flat File Schema through a Wizard :

1. Create a BizTalk project by navigating as shown in the figure




2. Select Empty Biztalk Project under biztalk templates



3. Now open notepad and type the following as shown below


After creating the notepad file, save it with appropriate file name of your choice 

4. Now switch back to visual studio and do the following:-  right click on project ----->add---->new item




5. On add new item dialog, select flat file schema wizard as shown below 



6. On the consecutive page give the path of your instance file name which you created in notepad and name the record name as EMP and click next




7. The next will show you all the record, select only one line of record as shown below. Do not check wrap long lines. 



8. On the next page select delimiter type as your file is a delimiter type.




9.  Proceed further by clicking the next button without modifying anything



10. Select record in element type and click next



11. Keep clicking the next button until you meet up with the screen shown below. Select (,) as child delimtier type and the proceed further by clicking the next button.


12. Proceed further and finish the wizard process. Now open properties of your falatfile schema and browse the file you want to five to give to your input instance filename. Similarly repeat the step for output instance filename.




13. Now validate your schema by right clicking on you schema file and selecting validate schema





14. After valdating schema repeat the step for validating instance. If validation is successful then a xml file instance would be created on the specified output instance file name path. Open your instance by holding the ctrl key and pointing to the path name showm in the output





15. You will find your xml output but this shows only one record.




16. For all records to show do the following as shown below




17. Your final output





 For beginners, it is strongly recommended to first make your schema using the wizard and then try making it manually wherein if in case you get stuck in the process you can quickly switch back to the properties window of schema made through the wizard.

 I hope it was a good read and  look forward to your queries and feedback.

Happy Blogging!!

Saurav Ambastha
Software Engineer @ Agility

No comments: