Click here to Skip to main content
15,879,239 members
Articles / Programming Languages / XML
Article

A Simple BizTalk Hands-On Example

Rate me:
Please Sign up or sign in to vote.
4.93/5 (19 votes)
23 Feb 20067 min read 168.7K   801   63   24
A simple example on using the BizTalk Server.

Introduction

Sometime back, I wrote an article on CodeProject titled "Explaining the BizTalk Architecture to your Grandma". This article got me a lot of feedback for a real hands-on example, and I committed to it at that time. So this article is delivering on that note. The target audience for this article is a BizTalk beginner, and the article is going to address two simple scenarios based on Content Based Routing (CBR) where the messages are directly subscribed between send and receive ports using filters on the message box. The scenarios are explained below.

Scenario 1

You would remember the port facility from the previous example. The example consisted of different packages/messages arriving and getting routed. In this case, the scenario is: there is a Receive Location where you get a file, and this needs to be copied to another folder on another machine (this could as well be another company location in Delhi connected through a company LAN).

Scenario 2

Scenario 2 is an extension of scenario 1. Here, what has occurred is your company WAN had some outage at Delhi and you had this sudden requirement to move this file to an FTP server. You will shortly see how easy it is to make this change in BizTalk.

A bird's eye view of the steps

This is a brief of the steps:

  • Define the Receive Port and Receive Location for the file.
  • Define the Receive Location properties.
  • Define the Send Port and configure the Port.
  • Define the filter which connects the Receive Port and the Send Port.
  • Start, enlist, deploy, and test our scenario 1.
  • Create a new Send Port for scenario 2 using FTP as Transport.
  • Configure this new Send Port and filters.
  • Start, enlist, deploy, and test our scenario 2.

Getting down to business ..

I have broken down the activity into a series of logical steps.

Step 1: The BizTalk Explorer

In Visual Studio .NET, if you have BizTalk installed, press Ctrl-Alt-Z to bring up the BizTalk Explorer. You can open this from the View menu also.

Image 1

Step 2: Creating the Receive Port and Receive Location

In the Explorer, expand your server node and right click on Receive Ports, and select Add Receive Port. In the next dialog box, select One-Way Port and click Next. In the dialog that appears, name our receive port AtlanticExpress.Pickup, and click OK. This will create our receive port AtlanticExpress.Pickup under Receive Ports.

Image 2

Step 3: Creating and configuring the Receive Location

Right click on Receive Locations under the receive port AtlanticExpress.Pickup that we just created, and on this new port, select Add Receive Location from the menu. In the dialog that appears, change the name to AtlanticExpress.Pickup.Location, then select the transport type as FILE from the list of available transport adaptors. Change the Receive Handler to BizTalkServerApplication (if you have given some other name for your BizTalk installation, that will appear in the drop down). Change the Receive Pipeline to Microsoft.BizTalk.DefaultPipelines.PassThruReceive. This means we are asking BizTalk to pass the file through without any processing like stripping Mime headers out or validating the party using our custom receive pipelines.

Recieve Location

Now in the Address (URI) field, use the “...” button to configure the file transport details. Create a directory C:\AtlanticWareHouse\Pickup on your local machine and select that as the Receive Folder as shown below. Configure File Mask as *.*. This means we are setting the mask to pickup any files. We can set this as *.txt, *.csv, or MyCustom*.xml if we want more control on what is picked up. Leave other values on their default as shown below:

Image 4

Step 4: Creating the Send port and configuring it

Now in the BizTalk Explorer, right click Send Ports and select Add Send Port. In the Create New Send Port dialog, choose Static One-Way Port (if not selected already) and click OK. In the Port Properties dialog, change the name to AtlanticExpress.Send. In the tree control under Configurations >Transport > Primary, set the Transport Type to FILE. Click the "..." button. To configure the Address (URI) field, create a folder on your local machine C:\AtlanticWareHouse\Drop and set this as the Destination folder (note: this could be your company WAN location in Delhi, in which case you could say \\DelhiServer\Shared\Drop). In the FILENAME field, put %SourceFileName%. This is a macro which tells BizTalk to retain the original file name. (Note: if you want unique names, you could use %MessageID%. This will create a random GUID as the filename.) Leave the Copy mode as Create New and click OK.

Image 5

Now, under Configurations > Send > General, set Send Pipeline to Microsoft.BizTalk.DefaultPipelines.PassThruTransmit. This means we are telling BizTalk to pass the whole file through without any extra processing. This is where we can use custom pipelines to encrypt or sign a message if we want.

The next step is what connects the Receive and Send ports together using a filter. As I said, this is a CBR scenario. BizTalk promotes certain context properties about the file into the message context associated with the file. The send port subscribes using this information. You could as well use your own custom fields here to decide routing. To do this, under Configurations > Filters & Maps > Filters, set BTS.ReceivePortName to AtlanticExpress.Pickup as shown below:

Image 6

Step 5: Revving it up

OK, now we have the basic stuff in place. We need to enable our Receive Location. Right click on AtlanticExpress.Pickup.Location and select Enable from the menu.

Image 7

Next, in the Send Port AtlanticExpress.Send, right click and select Start. This will first Enlist and then Start the Port.

Image 8

Now, drop a file in your pickup directory and you will see it disappear in a few seconds (wait for a minute or so the first time so that subscriptions get loaded), and look in your Drop directory. If you find the file there, congratulations you just completed your first BizTalk Hello World :-). Welcome to BizTalk!

Step 6: Modifying your example for Scenario 2 to use FTP

Now, remember, our scenario 2 is to modify this drop location from a file drop to an FTP drop. So, go back to BizTalk Explorer and right click AtlanticExpress.Send and Stop the Port, and then right click again and select Unenlist. Double click on the Port to open the configuration window. Now, under Configurations > Transport > Primary, set Transport Type to FTP. Click Address URI and it opens the dialog box below, and set the following properties: set Server to your server name (ftp.yoursite.com) or IP (say 67.15.21.10), set UserName (your FTP user name), set the Password for your FTP user, set Folder as the folder you want the file to be dropped, say /wwwroot/test. Set Target File Name as %SourceFileName%. Click OK.

Image 9

Now, you will come back to the Send Port properties and it should look like as in the figure below. Click OK to come back to the Explorer.

Image 10

Step 7: Testing the FTP scenario

Like in step 5 above, choose the Send Port AtlanticExpress.Send, right click and Enlist, and then Start. Now, go back to your drop folder and drop a file. Now log into your FTP location and browse to this directory. You should see your file there, and if you do, congrats you have completed scenario 2.

Points of Interest

You could modify this scenario in a lot of ways, You could, say, instead of modifying the Send Port, create a new Send Port and add both the Send Ports as a part of a Send Port Group which subscribes to the Receive Port. So the file will be dropped to both locations simultaneously. You can send the file over SMTP. The possibilities are endless. I will leave you to explore it. As a parting note, if you find any difficulty with the example, leave me a comment here, or ask me at this forum where I frequent more. You will also get a faster response as the forum has many BizTalkers.

History

  • Version 1.0 - February 21, 2005.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
United States United States
Abhilash is from Kerala, South India. He is presently working as an Integration Consultant for many fortune 500 companies in his current role at Neudesic

Abhilash has been programming since he got his first PC, when they used to load BASIC using tapes. He got his first real PC in 1994 - a 286 with a 40 MB hard disk, 1 MB RAM, and a 5.25 " FDD with a HGA graphics card.

Pascal was his first favorite programming language. And he thought at one time that it was the greatest language. He never really got on to the Delphi wagon, but went with C++, and then progressively VC++ SDK, MFC, COM, and then eventually chose C# as his preferred language once .NET came along. With the emergence of SOA into mainstream, Abhilash chose BizTalk as his SOA realization tool of preference. He opines that BizTalk helps implement SOA; by so clearly separating the message and the underlying implementation, and connect apps purely based on contracts. This is what many classic technologies like IDL tried to do, but somewhere, the point got lost. BizTalk is his tool of choice for EAI. Abhilash has worked in various platforms including Win32,.NET,Linux, and Mainframes and has professional experience in embedded development and voice telephony.This helps him understand the EAI domain better.

His passions include programming, blogging ,cricket and chess. He likes to troll MS user groups and used to run a site www.biztalkcafe.com as a hobby. The site has a forum, so if you work with BizTalk server, he would like to hear about your experiences there.

He was awarded Biztalk Server MVP in April of 2006.

His life events gets recorded here www.abhilash.in. You can connect with him on Linkedin

Comments and Discussions

 
PraiseBTS.ReceivePortName FTW Pin
hwassermann28-Mar-17 10:33
hwassermann28-Mar-17 10:33 
GeneralMy vote of 5 Pin
Ravindra.P.C9-Nov-16 23:17
professionalRavindra.P.C9-Nov-16 23:17 
GeneralMy vote of 3 Pin
vamshi1222122-Jul-10 1:17
vamshi1222122-Jul-10 1:17 
GeneralThe Simple BizTalk Hands-On Example Pin
Ed Fogarty12-Feb-09 7:14
Ed Fogarty12-Feb-09 7:14 
GeneralNot Working!! Pin
Shoba Anandhan20-Oct-08 2:03
Shoba Anandhan20-Oct-08 2:03 
GeneralRe: Not Working!! Pin
vemulasurendar17-Jan-14 1:41
vemulasurendar17-Jan-14 1:41 
GeneralVery helpful! Pin
Alex_ph28-Nov-07 22:31
Alex_ph28-Nov-07 22:31 
QuestionHow to Identify many Out File by Application name for different deployed Application???? Pin
ashwini_se22-Aug-07 8:05
ashwini_se22-Aug-07 8:05 
GeneralBTS with sql server babckend Pin
Member 393588819-Mar-07 0:52
Member 393588819-Mar-07 0:52 
GeneralMessage Closed Pin
16-Aug-07 4:56
ArrgHunter16-Aug-07 4:56 
Generaldeployment Pin
dave_tree13-Mar-07 0:38
dave_tree13-Mar-07 0:38 
GeneralRe: deployment Pin
saurinkhamar18-Apr-07 21:11
saurinkhamar18-Apr-07 21:11 
QuestionScenario 1 problem Pin
ifucanreadthisthenur2close6-Jul-06 9:50
ifucanreadthisthenur2close6-Jul-06 9:50 
AnswerRe: Scenario 1 problem [modified] Pin
ifucanreadthisthenur2close6-Jul-06 10:06
ifucanreadthisthenur2close6-Jul-06 10:06 
GeneralRe: Scenario 1 problem Pin
_ABHILASH_MS_6-Jul-06 12:43
_ABHILASH_MS_6-Jul-06 12:43 
GeneralRe: Scenario 1 problem Pin
Poornendulal.V7-Nov-06 22:15
Poornendulal.V7-Nov-06 22:15 
AnswerRe: Scenario 1 problem Pin
alex_vara12-Jul-06 5:50
alex_vara12-Jul-06 5:50 
AnswerRe: Scenario 1 problem Pin
alex_vara12-Jul-06 5:52
alex_vara12-Jul-06 5:52 
GeneralGood work again! Pin
Nish Nishant23-Feb-06 12:36
sitebuilderNish Nishant23-Feb-06 12:36 
GeneralRe: Good work again! Pin
_ABHILASH_MS_24-Feb-06 1:59
_ABHILASH_MS_24-Feb-06 1:59 
JokeRe: Good work again! Pin
Bravid24-Feb-06 2:50
Bravid24-Feb-06 2:50 
GeneralAnother great article... Pin
Rama Krishna Vavilala23-Feb-06 11:22
Rama Krishna Vavilala23-Feb-06 11:22 
GeneralRe: Another great article... Pin
Nish Nishant23-Feb-06 12:38
sitebuilderNish Nishant23-Feb-06 12:38 
GeneralRe: Another great article... Pin
_ABHILASH_MS_24-Feb-06 2:00
_ABHILASH_MS_24-Feb-06 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.