This type of transformations can occur in receive or send pipelines, usually text files (Flat Files) are processed at runtime as follows:
As mentioned earlier, to solve this problem we must create two artifacts:
BizTalk Flat File Schema Wizard tool, integrated in Visual Studio, which allows us to easily and visually make transformation of text file (Flat File) into its equivalent XML representation. This tool supports two types of text files:
Note: Header is in Portuguese “Cabeçalho”, therefore the text from the image is in Portuguese
The editor of pipelines, BizTalk Pipeline Designer, allows us to create, visualize and edit pipelines; move pipeline components between the different stages and configure pipelines components.
For this project we will use the BizTalk Server 2010 and Visual Studio 2010, and explain step by step what needs to be developed. Briefly these are the steps we have to perform:
Before we begin our development we need to create an instance, or sample of the text file that will serve as a model for the creation of the Flat File Schema. Therefore we will create the following text file on our file system that will be used in our solution:
Sandro;Pereira;1978-04-04;Crestuma;4415 Crestuma Lígia;Tavares;1982-01-21;Seixo-Alvo;451 Seixo-Alvo José;Silva;1970-09-19;Crestuma;4415 Crestuma Rui;Barbosa;1975-09-19;Lever;4415 Lever
To create the schema which will recognize the text file, we need to go to the BizTalk solution created in Visual Studio and perform the following steps:
To create the Receive Pipeline that will be responsible for processing and transforming the text file, we need to go to the BizTalk solution created in Visual Studio and perform the following steps:
All artifacts created yet must be installed on BizTalk Server 2010. However before we can deploy the solution there are some settings we need to do or guarantee:
Assign a name, for example "TXTtoXML.snk".
To learn more about these properties go to http://msdn.microsoft.com/en-us/library/aa577824.aspx
This is the final step of this process. In order to properly test the solution we have been developing in BizTalk Server, we need to configure the application that was created in the publication.
In the "Receive Locations" tab, select "New" and set the name to your receive location: "ReceiveTXT_to_XML"; in the property "Type" select the option FILE; and in the property "Receive pipeline" select from the drop down box the pipeline we created earlier: "ReceivePipelineCustomPessoas".
On the same tab select the "Configure" button. In the "FILE Transport Properties" window, set "Receive Folder" property, with the folder you created earlier "<solution>\PORTS\IN". On property "File Mask" put the following value: "*. txt", setting that will be processed only files with the extension. "txt". Finally select the "Ok" button.
To finish the process of creating the receive port press "Ok".
On the same tab select the "Configure" button. In the "FILE Transport Properties" window, set the “Destination Folder” property, with the folder you created earlier "<solution>\PORTS\OUT”. On property "File Mask" put the following value: “%MessageID%.xml”, this is special tag (BizTalk Macro) that will set the name of each file written on the file system with the unique identifier of the message. Finally select the "Ok" button to return to previous window.
In order for the Send Port subscribes to all files, we need to set a filter on the tab "Filters" with the following expression: "BTS.ReceivePortName == ReceiveTXT”.
Note: This setting will force each message in the MessageBox which has originates from the Receive Port: ReceiveTXT, be routed and processed by the Send Port we are finished creating.
To finish the process of creating the send port press "Ok".
To test the BizTalk application we only need to copy a text file to the directory that is configured on the receive location: "<solution>\PORTS\IN". The result should appear in the form of an XML document in the folder configured in the send port: "<solution>\PORTS\OUT".
As presented in this article, BizTalk Server helps us to solve many of the existing problems concerning message transformation: semantic and syntax Transformations, only with "out of the box" features within the product, in few steps and most of the time without developing any code.
Sandro Pereira DevScope | MVP & MCTS BizTalk Server 2010 http://sandroaspbiztalkblog.wordpress.com/ | @sandro_asp
Read suggested related topics:
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.
This article is also available in the following languages
Maheshkumar S Tiwari edited Revision 13. Comment: minor edit
Steef-Jan Wiggers edited Revision 11. Comment: Minor edit
Steef-Jan Wiggers edited Revision 9. Comment: Fixed typos
Ed Price - MSFT edited Revision 4. Comment: Title casing. Added tags. Great job!
There is a typo in fig. 5: "Party resolution". Is it from Visio? It might be easier to fix in that :)