Click here to Skip to main content
15,867,835 members
Articles / Programming Languages / C#
Article

First Footsteps with Orchestrations in BizTalk Server 2004

Rate me:
Please Sign up or sign in to vote.
3.33/5 (12 votes)
27 Feb 20065 min read 73.6K   177   31   13
An article on how to create a simple orchestration in BizTalk Server 2004.

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":

Image 1

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 NameProperty Value
RequestIdxs:string
CustomerNamexs:string
LoanAmountxs:int
AssetValuexs:int
DateRequestedxs:date

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

Image 2

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 NameProperty Value
RequestIdxs:string
CustomerNamexs:string
LoanAmountxs:int
Statusxs:string
Commentsxs: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:

Image 3

  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:
C#
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":

Image 4

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:

Image 5

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

Image 6

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


Written By
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.

Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

Comments and Discussions

 
QuestionError Message Pin
Anupam51818-May-14 23:07
Anupam51818-May-14 23:07 
GeneralOrchestration deployed and enlisted but output not as expected Pin
bhav27068013-Jan-09 0:19
bhav27068013-Jan-09 0:19 
GeneralThe published message could not be routed because no subscribers were found -updated Pin
bakee127-Oct-08 4:34
bakee127-Oct-08 4:34 
QuestionNo subscribers were found ??? Pin
zinc_z15-May-07 23:59
zinc_z15-May-07 23:59 
AnswerRe: No subscribers were found ??? Pin
Naveen Karamchetti16-May-07 4:03
professionalNaveen Karamchetti16-May-07 4:03 
GeneralRe: No subscribers were found ??? Pin
zinc_z16-May-07 5:13
zinc_z16-May-07 5:13 
GeneralRe: No subscribers were found ??? Pin
zinc_z16-May-07 5:39
zinc_z16-May-07 5:39 
Generalfirst steps in orchestrations : Output problem Pin
ThunderBiz6-Apr-07 5:34
ThunderBiz6-Apr-07 5:34 
Hi,
I gave the source xml file. I am getting the output in my output folder. I am seeing only the input file in the OUT folder, but not the destination file with the status. why ?
How does the orchestration work?

Moh
GeneralRe: first steps in orchestrations : Output problem Pin
Naveen Karamchetti6-Apr-07 5:58
professionalNaveen Karamchetti6-Apr-07 5:58 
GeneralFirst Footsteps In Orchestrations:Problem Pin
1207ashish22-Mar-07 7:19
1207ashish22-Mar-07 7:19 
GeneralRe: First Footsteps In Orchestrations:Problem Pin
Naveen Karamchetti22-Mar-07 8:08
professionalNaveen Karamchetti22-Mar-07 8:08 
QuestionNeed to Restart Biztalk services on every deployment ? Pin
Selvan30-Jul-06 8:18
Selvan30-Jul-06 8:18 
AnswerRe: Need to Restart Biztalk services on every deployment ? Pin
Naveen Karamchetti22-Mar-07 8:06
professionalNaveen Karamchetti22-Mar-07 8:06 

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.