Quantcast
Channel: Transformation – SANDRO PEREIRA BIZTALK BLOG
Viewing all articles
Browse latest Browse all 33

BizTalk Server: Transform text files (Flat Files) into XML – Conclusion (Part 4)

$
0
0

Configuring the BizTalk application

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.

For this, we will access the BizTalk Server Administration console to create and configure the following artifacts:

  • One receive port and location to process the input text files;
  • One send port to save the processed files in XML format…

Open the BizTalk Server Administration console under “Start –> Programs –> Microsoft BizTalk Server 2010”. On the left tree menu, maximize “BizTalk Server Administration –> BizTalk Group (…) –> Applications”, and look for the application called “TransfFlatFilesEmXML Demo” and maximize also this application.

maximize-BizTalk-Application

  • Press the right button on top of “Receive Port” menu and select “New –> One-Way Receive Port …” option;
  • A new window appears allowing us to define the port properties:
    • In the “General” tab, set the name of the receive port: “ReceiveTXT”.

New-receive-port

    • 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”;

New-receive-location

    • 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.

File-Adapter-Properties

    • To finish the process of creating the receive port press “Ok”.

The above steps mentioned were needed to create one Receive Port and its Receive Location. Now we will create a Send Port to save messages on the file system after they are processed by BizTalk:

  • Press the right button on top of “Send Ports” menu and select “New –> Static One-way Send Port…”
  • A new window appears allowing us to define the port properties:
    • In the “General” tab, set the name of the send port: ” SaveXMLFile “
    • In the property “Type” select the option FILE;
    • In the property “Send Pipeline” set the pipeline to “XMLTransmit”. This is a native pipeline that is used for processing XML messages.

New-send-port

    • 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 a 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 the previous window.

Send-port-File-Adapter-Properties

    • 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 originated from the Receive Port: ReceiveTXT, be routed and processed by the Send Port we are finished creating.

New-send-port-filter

    • To finish the process of creating the send port press “Ok”.

Finally, we need only to start our application. To do that press right button on top of the application name “TransfFlatFilesEmXML Demo” and select “Start …”.

start-BizTalk-application

Testing the solution

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”.

Note: The file disappears automatically from the input folder, so you should avoid doing drag & drop (move) with the test files at the risk of not being able to use it again.

Conclusion

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.

The fact of all the definitions of the rules of parsing (transformation rules) are embedded in the form of annotations in XML Schema (XSD), such as the delimiter symbols, or the element size in a positional file, simplifies the reuse of all these schemes in different parts of the process. At any point, the document can be translated back into flat-file because the definition is declarative and symmetric, in contrast to what might happen with a “normal” programming language like C#, where we would have to create two components to translate text to XML and vice versa.

The model used by BizTalk schemas, centralizes all the message definitions in a single artifact, simplifying the maintenance and evolution of the specification and therefore simplifying future reuse and dependencies management. When we set up this type of project, is exactly this kind of guarantees that keeps the systems operating properly for many years, and at the same time, they make life easier to those who one day have to correct and/or develop any of these processes

Related links

Source code

The solution of this example, as well all the code, is available on MSDN Code Gallery:
BizTalk Server – Transform text files (Flat Files) into XML (64.5 KB)
MSDN Code Gallery

The post BizTalk Server: Transform text files (Flat Files) into XML – Conclusion (Part 4) appeared first on SANDRO PEREIRA BIZTALK BLOG.


Viewing all articles
Browse latest Browse all 33

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>