Process Design with BizTalk Orchestration Designer

While many XML-based messaging servers offer the ability to transport and track XML messages in and out of systems, no application that can create and describe the processing flow a document must go through from start to finish exists. Enter BizTalk Orchestration Designer. This application, shown in Figure 15-6, allows you to drag and drop the necessary flowchart items to define a business process and then connect them to the implementation components used in processing the data.

Figure 15-6 The BizTalk Orchestration Designer.

Figure 15-6 shows you a visual representation of how these items are tied together, but as technologists we are sure you want to know and understand what is happening in the background. Behind the scenes, and after you have described your business process and its relationship to processing components, the Orchestration Designer creates an XLANG schedule. This schedule, which is saved with an .skx extension, is run by the XLANG Scheduler Engine, which controls the activation, execution, dehydration, and rehydration of the XLANG schedule. In other words, it handles the execution of the schedule details.

The functionality of the Orchestration Designer can be broken down into three areas. These are as follows:

To help you understand these items we are going to step through parts of an example, which will also familiarize you with the tool. This example will use the Orchestration Designer to route our technical support issue submission through our system.

Defining Work Flow

The first step we will take in creating this example is to define the business process workflow. For those of you familiar with Visio, the Orchestration Designer functions in much the same manner. Most of the time you drag components, shapes, and so forth, to your workspace and access properties of these items to define their functions. After you have launched the BizTalk Orchestration Designer, step through the following items to define the business workflow.

For all of these functions you will drag items from the Flowchart stencil on the leftmost side of the application to the left of the Separator bar.
  1. Drag an Action to a position below the Begin shape.
  2. Double-click the Action, and in the Name field enter Receive Email.
  3. Next drag a Decision shape and place it below the Receive Email action.
  4. Right-click the Decision shape and click Add Rule. In the dialog box that appears, type Phone and click OK. Repeat the same steps and add a second rule named Email.
  5. Add a second Action shape to the right of the Decision box and name it Phone Customer.
  6. Add a third Action shape below and to the left of the Phone Customer and name it Send Email.
  7. Below the Decision box, add a forth Action and name it Push To Manager.
  8. Finally we need to place three End items. Place one below the Push To Manager action, another below the Send Email action, and the last one below the Phone Customer action.

Now that all of our process descriptions are on the page, we need to connect these items. To connect them you need to follow these steps:

  1. Select an item by clicking on it so that a green outline shows.
  2. Select a control handle, which is represented by an x, of the first step in a process and drag it to one of the control handles of the action to which you want to connect it.

Connecting is this simple. In our example you will need to make the following eight connections:

At this point your screen should look like Figure 15-7. Now that this portion of our example is complete, save it in a file named Support.skv on the C drive. We will now begin adding our processing applications to the Implementation side of the workspace.

Figure 15-7 Our example after designing the workflow.

Referencing Processing Applications

One of the great qualities of the Orchestration Designer is its ability to include definitions and descriptions of the processing applications. For instance, we might want to use a component to send the customer with a support issue an e-mail with the resolution. Maybe we want to pass the document to a script first and perform other processing before a phone call is made to the customer. Using the Orchestration Designer we are able to drag category components to our workspace, select the scripts, COM objects, message queues, and BizTalk messaging applications that will be used to process the data.

In our example we are going to add a few script components. The point of this exercise is to expose you to some of the terminology and screens you should expect to see when defining the processing applications. For instance, you will create ports that act as the conduit between the business process and the applications. Furthermore, you will be able to see how the Orchestration Designer represents these connections.

The following steps will show you how to add Script Components out of the Implementation stencil.

  1. Drag a Script Component to the left side of the workspace, opposite the Phone Customer action. This will open the Script Component Binding Wizard dialog, where you will enter ProcessPhone as the name of the Port. Click Next when you have entered this name.
  2. Accept the default setting of Static on the second dialog and click Next.
  3. Now we have to specify a Script file. We are going to use one that was already built and is contained in a file called MsgBoxes.wsc (Listing 15-6). This should be located in the \Program Files\Microsoft BizTalk Server\ SDK\XLANG Samples\Loop\LoopApp directory if you installed the application in its default location. Here are the contents of the file in case you did not:

    Listing 15-6 MsgBoxes.wsc: A script used to display our dialog boxes.

    <?xml version="1.0"?>
    <?component error="true" debug="true"?>
    	<method name="ShowMsgBox">
    		<PARAMETER name="sMsg"/>
    		<PARAMETER name="sTitle"/>
    	<method name="AskYesNo">
    		<PARAMETER name="sMsg"/>
    		<PARAMETER name="sTitle"/>
    <script language="VBScript">
    function ShowMsgBox(sMsg, sTitle)
    	MsgBox CStr(sMsg), vbOKOnly, CStr(sTitle)
    	ShowMsgBox = ""
    end function
    function AskYesNo(sMsg, sTitle)
        AskYesNo = MsgBox(CStr(sMsg), vbYesNo, CStr(sTitle))
    end function
  4. After you've clicked Next you will select the instantiation option for the component. Leave this setting at Use the ProgID MsgBoxes.WSC. Click Next when you are finished.
  5. On the Method Information dialog, select only the ShowMsgBox method and click Next.
  6. On the final screen, Advanced Port Properties, we will accept all the default settings and click Finish.
  7. Now repeat these steps to handle the processing of the Send Email and Push To Manager actions. All you need to do is change the name of the Port in Step #1 to ProcessEmail for one instance, and ProcessManager in the second.
Want to know more about the other Implementation components? Be sure to check the BizTalk Help files—they contain more information, as well as other tutorials.

Once you've completed these steps, the right side of your workspace should look like Figure 15-8.

Figure 15-8 The results after connecting to processing scripts.

Before we move on, let's include a processing component that will be responsible for starting the entire process. This component, which will be of the Message Queuing type, will be what feeds the Receive Email action we defined on the business process setup. Here are the steps for adding this component.

  1. Drag a Message Queuing component to the left side of the workspace, opposite the Receive Email action. This will open the Message Queuing Binding Wizard dialog, where you will enter IncomingEmail as the name of the Port. Click Next when you have entered this name.
  2. Accept the default setting of Static on the second dialog and click Next.
  3. Now we need to include the queue information. For this example we will create a new queue for every instance. Simply accept the default setting and hit Next. (If you've forgotten how, check back in Chapter 7 for message queuing details.)
  4. On the final screen, Advanced Port Properties, we will accept the default settings, so just click Finish.

At this point we have all the pieces in place—we just need to properly associate them and apply any needed functionality. In the next section, we will attach our business actions to our processing scripts and put the finishing touches on our example.

Attaching Steps to Processing

The final step in our example of using the Orchestration Designer application is to connect the business steps to the processing applications (scripts in our case). This step will not only involve defining the processing connections, but we will also add information in our Decision item to determine which connection is used.

In the same manner we used to connect the items together in the business process, we will drag control handles from the appropriate actions to the corresponding script component port. The following outlines how to complete this process.

Remember that the "port" is defined by the name we gave it. You can see these ports in the middle of your workspace.
  1. Grab the rightmost control handle for the Receive Email action and drag it to the leftmost handle on the IncomingEmail port. This will cause the XML Communication Wizard to appear.
  2. Select the Receive option to signify that the XLANG Scheduler Engine will be receiving the message. Click Next after you have entered this information.
  3. On the following Message Information dialog, enter SupportMessage as the name of the message, and click Next.
  4. Accept the default setting of Receiving XML Messages From The Queue on the XML Translation Information dialog and click Next.
  5. On the Message Type Information dialog, enter <support> as the Message Type and click Next.
  6. On the following screen browse to our mapping.xml specification and click Finish to finalize the association.
  7. Next grab the rightmost control handle for the Phone Customer action and drag it to the leftmost handle on the ProcessPhone port. This will cause the Method Communication Wizard to appear.
  8. On the initial dialog accept the default of initiating a synchronous method call and click Next.
  9. Click Next again on the Message Information dialog. This will present you with the third and final dialog that outlines the details of the ShowMsgBox method. Click Finish when you are done.
  10. Repeat steps 7—9 for the connection between the Send Mail action and the ProcessEmail port.
  11. Repeat steps 7—9 for the connection between the Push To Manager action and the ProcessManager port.

Once you have completed these steps, your workspace should look like Figure 15-9.

Figure 15-9 The workspace after completing the process-to-port connections.

The next step in our example is to write the expressions to evaluate our document so we can properly process the data. Follow these steps to add in the necessary expressions:

  1. Right click on the Decision item and select Properties. This will launch a dialog box displaying our Phone and Email rules.
  2. Select the Phone rule and click the Edit button.
  3. In the Rule Properties dialog place your cursor in the Script Expression textarea. Now type SupportMessage.Phone > 1. Click Ok when you are finished.
  4. Repeat Steps 2—3 for the Email rule and enter SupportMessage.Email > 1 for the expression.
What does this mean? Typing SupportMessage.Phone signifies that we are looking for the presence of a phone number in the document submitted. If this evaluates to TRUE, we will go through the ProcessPhone port and run the proper script.

We are now finished. Save your file so you do not lose any changes. At this point you should be able to combine what you've learned here with what we covered in Chapter 7 to build a complete BizTalk solution, or at least a simple one.

If you are still interested in the BizTalk Framework and Server product, check out . You will find several Microsoft Press titles on the subject.