BizTalk Orchestrations

In this article, I will cover one important component of Microsoft BizTalk Server, the orchestrations. Basically an orchestration is the executable code to run a workflow supporting a business process. Orchestration interacts with outside entities by using the ports. All these things together are a powerful tool to perform process automation.


In this article, I will cover one important component of Microsoft BizTalk Server, the orchestrations. Basically an orchestration is the executable code to run a workflow supporting a business process. Orchestration interacts with outside entities by using the ports. All these things together are a powerful tool to perform process automation.

What is an orchestration?

An orchestration is the executable implementation of a business process, that is, a logical and chronological set of activities in order to achieve a goal. In order to interact with systems and applications outside the boundaries of the orchestration, you can use send and receive ports. Orchestration allows modeling the business process visually and it is the primary mechanism to automate the process within a solution. They are created in Visual Studio and compiled into .NET assemblies that are deployed in the Global Assembly Cache and registered in the BizTalk Management database.

The tool used to define the orchestration is BizTalk Orchestration Designer which presents a visual development environment for specifying the process flow separately from the implementation of the individual activities in the process. It is possible to link each activity with its implementation on representing the interaction with an application or a system that is external to the orchestration itself.

Orchestrations are executed by the BizTalk orchestration engine which is the maestro and runtime environment that manages the life cycle of the orchestrations such as instantiation, execution, termination and migration across host instances as well as schedule and monitor the interaction with external entities.

The BizTalk engine consists technically by a set of SQL Server databases with stored procedures and jobs running on the MessageBox database and Management database as well as a set of managed assemblies which run within BizTalk host instances. XLANG is the main language use to specify and execute the workflows.

From the architecture viewpoint, orchestrations are tied to the MessageBox database which receives messages from receive ports and dispatch messages through the send ports. Each instance of the orchestrations is listening for activity based on the subscriptions to the underlying orchestration definition (see Figure 1).


Figure 1

Getting started with an example

In order to specify the workflow associated to an orchestration, we need to use the Orchestration Designer. Follow the following steps to get started using orchestrations:

  1. Start Visual Studio 2005.

  2. Create a new project by clicking File|New|Project, selecting the BizTalk Project node in the Project Types tree, and entering the name PurchaseOrderProj.

  3. Create an orchestration by clicking Project|Add New Item and enter the name PurchaseOrderOrchestration as shown in Figure 2.


    Figure 2

  4. The Orchestration Designer has been divided in three sections: two port surfaces and an -orchestration flowchart area. You have also a Toolbox window with orchestration shapes and the Orchestration View window. You can drag-and-drop various toolbox shapes onto the flowchart area as shown in Figure 3.


    Figure 3

  5. Let's define the simple PurchaseOrder business process. As an illustrative example, this process is straightforward. A PurchaseOrder document is received, and then this order is sent to the Warehouse system and Financial system at the same time. Add a Receive shape, two Send shapes within a Parallel Actions shape (see Figure 4).

  6. Now, let's configure the shapes. Click on the Receive shape and go to the Property windows and set the name to Receive_PurchaseOrder, Activate to True. Set the name for the Send shapes: one is named Send_PurchaseOrder2WarehouseSys and the other is named Send_PurchaseOrder2FinanancialSys (see Figure 4).

  7. Figure-4.gif

    Figure 4

  8. Now let's define the message schema for the PurchaseOrder document by adding a XSD Schema artifact named PurchaseOrder.xsd to the project as shown in Figure 5.


    Figure 5

  9. Now that we've defined the schemas for information containers, right-click on the Messages node in the Orchestration View window in the Orchestration Designer and select New Message, go to the Property window and set Identifier to PurchaseOrderMsg and MessageType to the previously created schema (see Figure 6).


    Figure 6

  10. Next go to the Receive shape and the two Send shapes (you can see the exclamation icons on these shapes telling that some configurations on these shapes are missing) and set the Message property pointing to the message PurchaseOrderMsg (see Figure 7).


    Figure 7

  11. Now let's add and configure the ports which are the communication channels between the orchestration and external systems. Let's assume that the communication between the orchestration and the Warehouse and Financial Systems is through documents dropped in the underlying directories of the file system. Create three directories one directory named purchase_order_orch for the input doc and two directories named warehouse_sys_dir and financial_sys_dir for the output in a temp area.

  12. Right-click over the Port Surface and select New Port. Then right-click on the newly created port and select Configure Port. Enter the name: Receive_PurchaseOrder_Port and click Next, in the Select a Port Type page set data as shown in Figure 8, and click on Next.


    Figure 8

  13. In the Port Binding page, select as shown in Figure 9, click Next and finish the wizard.


    Figure 9

  14. Drag and drop the green icon on the left side of the Port to the green icon on the Receive shape to create a link from the logical item in the orchestration to the physical world.

  15. Execute the same steps from 12 to 14 to create the Send Ports, but in the Port Binding page set the Port Direction option to I'll always be sending messages on this port. After you have finished the steps, finally your orchestration should resemble Figure10.


    Figure 10

Biztalk orchestrations and the underlying artifacts such as xsd schemas, mappings and pipelines are hosted in .NET assemblies, and they should be visible to BizTalk engine, thus the assemblies generated for BizTalk must be deployed into the Global Assembly Cache (GAC). Before an assembly is deployed into the GAC, it must have a strong name which helps the .NET Framework uniquely identify assemblies in the GAC. Strong name requires a strong name key generated by the tool sn.exe which is part of the .NET Framework SDK.

In order to generate a strong name using the sn.exe tool for your solution, do the following steps:

  1. Open a command window and go to the solution directory.

  2. Execute the command sn -k PurchaseOrderProj.snk as Figure 11.


Figure 11

Now let's assign these key pairs to the project, build and deploy the solution by doing the following steps:

  1. Open the Property Pages for the project by clicking on PurchaseOrderProj Properties.

  2. Select the Common Properties|Assembly node in the left pane and in the right pane set the property Assembly Key File to the path of the file with the generated key pairs as shown in Figure 12.


    Figure 12

  3. Select Build|Build PurchaseOrderProj.

  4. Select Build|Deploy PurchaseOrderProj.

Now it's time to configure the solution in the deployment BizTalk server. Because you have created one receive port and two send ports and they are not unbound to any physical connection because you deferred the specification of the port bindings (see the Port Bind option set to Specify Later in Figure 9).

In order to configure the physical port of the solution, do the following steps:

  1. Start the Biztalk Server Administration Console application and navigate to your application node in the Applications sub-tree. You can see all your solution artifacts by clicking on the associated node.

  2. First, let's create a receive port. Go to the Receive Ports nodes, right-clicking on it and selecting New|One-way receive Port. Name the port as ReceivePOPort (see Figure 13).


    Figure 13

  3. Click Receive Locations tab, and New button to add a new location by clicking on the New button. Set PurchaseOrder_FS_RL as the name of the location, and change the Type setting in the Transport area to File. You can also configure the pipeline to use. Set the pipeline:
    XMLReceive because no document processing is required (see Figure 14).


    Figure 14

  4. Click on the Configure button to set the directory where the documents are received from (see Figure 15).

    Figure 15

  5. Click OK to complete the configuration.

  6. Now let's start the Receive Location by navigating to the Receive Location nodes and right-click on the newly created Receive Location and selecting the Enable option (see Figure 16).


    Figure 16

Now, you need to create two physical send ports.

  1. Right-click the Send Ports and select New|Static One-way Send Port.

  2. Change the port name to SendPO_2Warehouse_SP.

  3. Change the Transport Type setting to File, and click the Configure button. Click on Browse button to find the output directory. Set the pipeline to XMLTransmit.

  4. Leave the default output file and the final configuration is shown in Figure 17.


    Figure 17

    5. In order to start the port by right-click on the newly created port and select Start option (see Figure 18).


    Figure 18

    6. Do the same steps to create the Send Port for the Financial System.

Once you have created all the necessary ports for the input and outputs of your physical messages, it is time to bind them to the orchestration.

  1. Click on the orchestration PurchaseOrderProj.PurchaseOrderOrchestration select Properties.

  2. In the Properties window, click on the Binding options.

  3. Change the Host setting to BiztalkServerApplication.

  4. Change the binding as shown in Figure 19.


    Figure 19

    5. Right-click on the orchestration and select Start.

    Now you can test the solution by copying an XML document with structure defined by the schema inside the input folder and wait the response of the process in the output folders.


In this article, I covered principles of the orchestrations as well as I illustrated how to create and run a simple orchestration using the Orchestration Designer shipped with Visual Studio.