BizTalk Training 2 – Receive/Send Plain Text

This entry is part 2 of 5 in the series BizTalk Training

Receive/Send Plain Text

This tutorial shows how to receive plain text using FILE Adapter and map to xml message while in orchestration and finally send out using FILE Adapter as plain text.

There are 5 tutorials in this training.

  1. BizTalk Training 1 – basic send/receive xml message
  2. BizTalk Training 2 – receive/send plain text
  3. BizTalk Training 3 – customize filename dynamically
  4. BizTalk Training 4 – using Functiods in Map
  5. BizTalk Training 5 – using FTP Adapter

Objectives

  • Learn to create schema using Flat File Schema Wizard.
  • Learn to receive file which is plain text to BizTalk.
  • Learn to send file from BizTalk to plain text.

Prerequisites

  • BizTalkTraining 1 project.
  • Configuration on BizTalk Administration for BizTalkTraining application.

Topics

  1. Create schema from plain text using Flat File Schema Wizard.
  2. Add receive and send pipeline for receive/send plain text.
  3. Modify orchestration.
  4. Deploy the project.

Step-by-step

As from training 1, I have sample file which is an xml message. Now what if I want a plain text as an input, BizTalk can receive any file format which you can determine the schema in pipeline.

Suppose, I have the same data as in training 1 but it’s a plain text instead of xml in C:\FILE2\person1.txt.
Example plain text

  1. Create schema from plain text using Flat File Schema Wizard.
    • Open existing BizTalkTraining project, Add New Item to the project.
      Add new Item
    • Select Schema Files -> Flat File Schema Wizard and name the schema as “FlatFilePersonSchema.xsd”.
      Flat File Schema Wizard
    • BizTalk Flat File Schema Wizard appears, click Next.
    • On Instance file, click Browse and select the sample text file that you want to create schema from. Change Record name to ‘Person’ and click Next.
      Flat File Schema Information
    • On Select Document Data, leave the data highlight and click Next.
      Select Document Data
    • Click Next.
      Select Record Format
    • Ensure that Child delimiter is {CR}{LF} which means split data with new line characters. Click Next.
      Delimited Record
    • Change Element Names and Data Types as in figure below.
      Child Elements
    • Click Finish.
      Schema View
    • Now that you have created a schema file from plain text.
      FlatFilePersonSchema.xsd
  2. Add receive and send pipeline for receive/send plain text.
    • Add New Receive Pipeline.
      Right click on the project -> Add New Item -> select Pipeline Files -> Receive Pipeline -> name as ReceivePersonPipeline.btp.
      Add new Item
    • New receive pipeline appears.
      ReceivePersonPipeline.btp
    • Drag Flat File disassembler to Disassemble stage.
      Flat File disassembler
    • Click on Flat file disassembler object that you’ve just dropped.
      On Properties, change Document schema to “BizTalkTraining.FlatFilePersonSchema” which is the schema that we’ve created previously.
      Change Document schema
    • Now add new Send Pipeline.
      Right click on the project -> Add New Item -> select Pipeline Files -> Send Pipeline -> name as SendPersonPipeline.btp.
      Add new Item
    • Drag Flat file assembler to Assemble stage.
      SendPersonPipeline.btp
    • Click on Flat file assembler object that you’ve just dropped.
      On Properties, change Document schema to “BizTalkTraining.FlatFilePersonSchema” which is the schema that we’ve created previously.
      Change Document Schema
    • Now you’ve configured receive pipeline for receive plain text and send pipeline for send to plain text.
  3. Modify orchestration.
    • Back to Orchestration1.
      Orchestration1
    • Change the schema from person1.xsd to FlatFilePersonSchema.xsd on ports and receive/send components.
      1. Break the green link between ports and receive/send components by right click on the line and select Delete.
        Delete link
      2. Now orchestration will look similar below.
        Delete link
      3. Change message type for msgPerson.
        • On orchestration1, switch to Orchestration View.
        • Select msgPerson.
        • On Properties, change message type to “BizTalkTraining.FlatFilePersonSchema” which is the schema that we’ve created recently.
          Change message type on msgPerson
      4. Change message type on both ports.
        • Click Request on RecvPersonPort. Be sure that you click on Request which inside the port, you’ll notice the highlight only around in Request not entire port.
        • On Properties, change message type to “BizTalkTraining.FlatFilePersonSchema” which is the schema that we’ve created recently.
          Change message type on ports
        • Repeat change message type on SendPersonPort, too.
      5. Connect ports and receive/send components back.
        Connect ports back
    • Modify RecvPersonPort.
      • Click on RecvPersonPort and move to Properties window.
      • Change the Receive pipeline to “BizTalkTraining.RecvPersonPipeline” which is the receive pipeline that we’ve created.
      • Change the URI (Receive location) to “C:\FILE2\IN\*.txt”.
        Change pipeline and receive location
    • Modify SendPersonPort.
      • Click on SendPersonPort and move to Properties window.
      • Change the Send pipeline to “BizTalkTraining.SendPersonPipeline” which is the send pipeline that we’ve created.
      • Change the URI (Receive location) to “C:\FILE2\OUT\%SourceFileName%”.
        Change pipeline and receive location
    • You’ve just configured to receive plain text (*.txt) from a folder to send to another folder as plain text.
  4. Deploy the project.
    • Right click on Solution ‘BizTalkTraining’ and select Deploy Solution.
      Deploy the project
    • The output window will show status of the deployment.
      Deployment status
    • If you have deployed this project before (in Training 1), you need to restart BizTalkServerApplication and refresh the application.
      1. Expand BizTalk Server 2006 Administration -> BizTalk Group -> Platform Settings -> Host Instances.
      2. Right click on the host which runs BizTalkTraining application (Host type as In-Process) and click Restart.
        Restart the server host instance
      3. Next, refresh the application by right click on BizTalk Training and select Refresh. Now your application on BizTalk is up-to-date.
        Refresh the application
    • If you haven’t deployed this application before, go back to Training 1 for further detail.
    • Now you can test by drop person1.txt to C:\FILE2\IN and wait for result come out in C:\FILE2\OUT.

Resources

You can download the example source code (zip file) at here.
The zip file contains

  • BizTalkTraining folder which is the example project on Visual Studio 2005.
  • FILE2 folder which contains IN and OUT empty sub folders for test receive and send message and person1.txt which is an example text message.
  • binding.xml file which is a configuration file for import in BizTalk Administration.
Series Navigation<< BizTalk Training 1 – Basic Send/Receive XML MessageBizTalk Training 3 – Customize Filename Dynamically >>

10 Comments

  1. John November 10, 2007
  2. Sam July 31, 2008
  3. linglom July 31, 2008
  4. sandrar September 11, 2009
  5. Salam February 22, 2010
  6. linglom February 23, 2010
  7. Shadab Hasan December 27, 2010
  8. rajni January 8, 2011
  9. kashif January 12, 2014
  10. RAJ November 24, 2015

Leave a Reply