4,816,711 members and growing! (5,100 online)
Email Password   helpLost your password?
Enterprise Systems » Microsoft BizTalk Server » General     Intermediate

First Footsteps with Orchestrations in BizTalk Server 2004

By Naveen Karamchetti

An article on how to create a simple orchestration in BizTalk Server 2004.
C#, Windows, .NET, WinXP, Win2003, .NET 1.1, VS, VS.NET2003, Dev

Posted: 27 Feb 2006
Updated: 27 Feb 2006
Views: 20,331
Announcements


Search    
Advanced Search
Sitemap
print Print Broken Article? Broken Article? Discuss Discuss Recommend Article Send to a friend
11 votes for this Article.
Popularity: 3.50 Rating: 3.36 out of 5

Introduction - First things first!

When I first started learning BizTalk, I was looking for an article that could quickly show me how to build a simple orchestration (also known as "Business Process"). Unfortunately, I was unable to find one, so this is my attempt at demonstrating a simple orchestration. Please note that BizTalk Server 2004 is being used in the entire article.

Loan processing application - orchestration demo

Let us consider a simple loan processing request, where in a customer applies for a loan, and the loan request is either "APPROVED" or "REJECTED" based on the customer's ability to repay the loan.

Loan processing - business process

  1. A customer submits a loan processing request; we will call it a loan request.
  2. A business process determines whether the loan can be "APPROVED" or "REJECTED".
  3. A response is generated by the BizTalk which is sent back to the customer.

Creating the BizTalk project - "LoanProcessing"

Now let's start. Create a new BizTalk Server project in Visual Studio.

Step 1: In the Visual Studio .NET menu, select the File -> New -> "Blank Solution" and type the name "LoanProcessing":

Step 2: In the Solution Explorer, right click on the solution name "LoanProcessing" and select Add -> New Project. In the "Add Project" dialog box, for the type of the project, select "BizTalk Projects". Select the template "Empty BizTalk Project" and create a project named "Loan".

Building the schemas

We need to create two schemas; one is the "Loan Request" and other for "Loan Response". At the end of this section we would be ready with the following artifacts:

  1. LoanRequest.xsd
  2. LoanResponse.xsd

Loan request schema

Step 3: Right-click on the project in the Solution Explorer and select the "Add New Item" option. Then, select the item "Schema" and name it "LoanRequest". When the schema shows up, rename the "Root" element to "LoanRequest". After that, create the child elements: "RequestId", "CustomerName", "LoanAmount", "AssetValue", "DateRequested":

Request Schema Elements
Property Name Property Value
RequestId xs:string
CustomerName xs:string
LoanAmount xs:int
AssetValue xs:int
DateRequested xs:date

Please look at the image below and confirm your schema file:

Loan response schema

Step 4: Right-click on the project in the Solution Explorer and select the "Add New Item" option. Then, select the item "Schema" and name it "LoanResponse". When the schema shows up, rename the "Root" element to "LoanResponse". After that, create the child elements: "RequestId", "CustomerName", "LoanAmount", "Status", "Comments":

Response Schema Elements
Property Name Property Value
RequestId xs:string
CustomerName xs:string
LoanAmount xs:int
Status xs:string
Comments xs:string

Building the map

We need to build a map which would transform a loan request XML document into a loan response XML document. A map in BizTalk is a behind-the-scene XSLT file.

Step 5: Right-click on the project in the Solution Explorer and select the "Add New Item" option. Then, select the item "Map" and name it "LoanRequest-To-LoanResponse-Map". Notice the file name convention used here, "SourceSchemaName-To-TargetSchemaName-Map".

Step 6: Click on the left link "Open Source Schema" and select "LoanRequest". Click on the link "Open Destination Schema" and select "LoanResponse". Complete the mapping as shown in the picture below:

  1. Select the "Scriptoid Function".
  2. Click on the property "Configure Functoid Script".
  3. Select C# as "Script Type", and copy and paste the code in the script function:
public string LoanProcessing(int loanAmount, int assetValue) 
{ 
    if ( loanAmount < assetValue) 
    {    
        return "APPROVED"; 
    } 
    else 
    { 
        return "REJECTED"; 
    } 
}

Building the orchestration (also known as a "Business Process")

In an orchestration, a message is the unit of processing. A "message" will always be processed. A "message" can be of any XML schema type. In this project, we have defined two schemas, so ideally we would have two messages in this orchestration.

Step 7: Right-click on the project in the Solution Explorer and select the "Add New Item" option. Then, select the item "BizTalk Orchestration" and name it "LoanOrchestration":

Step 8: Place three shapes on the "Orchestration Surface":

  1. Receive shape
  2. Transform shape
  3. Send shape

Step 9: Create two messages:

  1. LoanReq, and in the Properties Window, set the message type as "Loan.LoanRequest".
  2. LoanResp, and in the Properties Window, set the message type as "Loan.LoanResponse".

Step 10: Setting the properties for all the shapes:

  1. Select the Receive shape, and in the Properties Window, set the message type as "LoanReq" and "Activate" as True.
  2. Select the Send shape, and in the Properties Window, set the message type as "LoanResp".
  3. Select the Transform shape and set the properties as shown in the figure below:

Step 11: Create two ports (a receive port and a send port).

  1. Receive port: Right-click on the port surface, and select "New Configured Port", and give it a name "ReceivePort", leave all the default properties as it is in the wizard.
  2. Send port: Right-click on the port surface, and select "New Configured Port", and give it a name "SendPort", leave all the default properties as it is in the wizard.

Step 12: Strong name and deployment!!

  1. Create a key file using the "sn -k LoanKey.snk" in the Visual Studio .NET command prompt.
  2. In the Solution Explorer, right-click on the "Loan" Project Properties and select "Assembly" and specify the key file name.
  3. In the Solution Explorer, right-click on the "Loan" Project Properties and select "Deploy".

Step 13: Refresh - BizTalk Explorer and create send port and receive locations.

  1. Please refer to MSDN documentation on how to create send port and receive locations.

Step 14: Test the solution

  1. Place the input file in the receive location. Check the response in the output folder.

Quick takeaways

  1. Always set the Activate property to "true" for the first Receive shape in the orchestration.
  2. The first step in an orchestration is to decide the number of messages flowing through the business process and then creating them.
  3. A BizTalk message is always associated with a schema (except in the case of un-typed messages).
  4. A BizTalk service needs to be re-started every time a deployment is done.

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

About the Author

Naveen Karamchetti


Naveen Karamchetti has done his Masters (M.S.) in Software Engineering from B.I.T.S, Pilani and is based out of Fremont, CA.
The author has more than 8.5 yrs of experience in the IT industry, has started his career
starting from the good old days of using a Unix, Tcl/tk. The author has been associated with
several companies based out of Silicon Valley, California.

The author has won several programming awards within the organizations worked and is well-recognized. The author has also worked for Microsoft based at Redmond.

Hobbies include training, mentoring and research. Spends his free time travelling in the BART (Bay Area Rapid Transit) in Fremont, CA.

Occupation: Software Developer (Senior)
Location: United States United States

Other popular Microsoft BizTalk Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
 FAQ Noise Tolerance Search comments 
 Layout  Per page   
 Msgs 1 to 10 of 10 (Total in Forum: 10) (Refresh)FirstPrevNext
Subject  Author Date 
No subscribers were found ???zinc_z0:59 16 May '07  
Re: No subscribers were found ???Naveen Karamchetti5:03 16 May '07  
Re: No subscribers were found ???zinc_z6:13 16 May '07  
Re: No subscribers were found ???zinc_z6:39 16 May '07  
first steps in orchestrations : Output problemThunderBiz6:34 6 Apr '07  
Re: first steps in orchestrations : Output problemNaveen Karamchetti6:58 6 Apr '07  
First Footsteps In Orchestrations:Problem1207ashish8:19 22 Mar '07  
Re: First Footsteps In Orchestrations:ProblemNaveen Karamchetti9:08 22 Mar '07  
Need to Restart Biztalk services on every deployment ?Selvan9:18 30 Jul '06  
Re: Need to Restart Biztalk services on every deployment ?Naveen Karamchetti9:06 22 Mar '07  

General    News    Question    Answer    Joke    Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Feb 2006
Editor: Chris Maunder
Copyright 2006 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2008
Web07 | Advertise on the Code Project