Module 9: Automating Business Processes

advertisement
Module 9: Automating Business Processes
Time estimated: 120 minutes
Module objective:
In this module, you will learn:
How to build an orchestration to automate a business process
Overview
Orchestration is a flexible, powerful tool for representing your executable business processes.
You can design the message flow, interpret and generate data, call custom code, and organize it
all in an intuitive visual drawing. It is important for you to become familiar with the various
shapes that Microsoft® BizTalk® Orchestration Designer provides to represent the logical flow of
your orchestration. You should also know how to manipulate data and manage exceptions
within an orchestration.
Lesson 1: Controlling the Flow of an Orchestration
Lesson objective:
Use orchestration flow control shapes and create modular orchestrations.
Overview
Orchestration Designer provides a number of shapes that you can use to control the flow of
your orchestration. In this lesson, you will learn how to use and configure the Group and Scope
shapes to organize your orchestration and how to use different shapes to control parallel
processes and conditionally control the flow of messages through the orchestration.
Scope and Group Shapes
Explain how scope shapes and group shapes are used to organize actions in an orchestration.
Scope Shape
A scope acts as a framework for organizing actions. You use it primarily for transactional
execution and for exception handling. You also use a scope when you want to define variables,
messages, and correlation sets that must remain local within the scope and when you need to
use variables and classes that are non-serializable.
A scope contains one or more blocks or other nested scopes. It has a body and can have
appended to it any number of exception-handling blocks. It may also, depending on the nature
of the scope, include an optional compensation block. For more information on compensation,
see Module 10, “Creating Transactional Business Processes”.
Some scopes exist solely for the purpose of exception handling, and these do not require
compensation. In Microsoft .NET terms, a scope is a Try block that can have multiple catch
(exception-handling) blocks. Other scopes are explicitly transactional. Transactional scopes
always have a single compensation block and can include a time-out value. You can write your
own or use the default compensation handler.
The scope shape creates an additional context within the orchestration. The scope can have its
own variables, messages, and correlation sets. The memory used for these will be freed up
when all of the actions within the Scope shape complete.
Synchronized vs. Not Synchronized
You can specify that a scope be either synchronized or not synchronized. By synchronizing a
scope, you ensure that parallel actions in your orchestration do not write to any shared data
accessed by the orchestration and that no actions will write to the shared data while another
action reads that same shared data. Atomic transaction scopes are always synchronized.
All actions in a synchronized scope are considered synchronized, as are all actions in any of its
exception handlers. Actions in the compensation handler for a transactional scope are not
synchronized.
Group Shape
A Group shape is used to arrange actions in an intuitive and visually manageable way. You can
use the Group shape as a placeholder for functionality yet to be added, or you can use it to
make annotations about what actions take place within it. The name property on the Group
shape can be up to 512 characters long. You can type annotations into the name property, and
when the shape is collapsed, the entire name will be displayed.
Orchestration Flow Control Shapes
Configure orchestration shapes to enable decision logic and event timing within an orchestration.
Orchestration Flow Control Shapes
The Orchestration Designer provides a number of shapes that you can use to control the flow of
your orchestration. Most of these shapes are configured with one or more expressions that are
defined using the BizTalk Expression Editor.



Decide. Represents If/Else logic. The Decide shape always has at least two branches: a
branch for the If statement and a branch for the Else statement. You can add branches
for If/Else statements as needed. A rule (written as a Boolean expression) is defined for
each branch of a Decide shape except the Else branch. Rules are evaluated left to right,
and only the first matching rule branch will be executed. If none of the rule conditions is
met, the Else branch will be executed. Each branch can contain additional orchestration
shapes, including other Decide shapes (to create nested if statements).
Delay. Controls the timing of the orchestration’s progress. You can set a time-out on the
Delay shape so that your orchestration pauses before resuming execution. You can use a
System.DateTime structure, which will cause your orchestration to pause until the
specified date or time is reached, or you can use a System.TimeSpan structure, which
will cause your orchestration to pause for the length of time specified.
Listen. Requires an orchestration to wait for one or more events to occur before
proceeding. The first shape in each branch of a Listen shape must be either a Delay
shape or a Receive shape. The orchestration follows only the first branch that meets the
condition (for example, a delay is reached or a message is received).You can add as
many branches as you like.
Orchestration Flow Control Shapes (continued)
Configure orchestration shapes to enable repeating actions and concurrent processing and to
suspend or terminate an orchestration process.
Orchestration Flow Control Shapes (continued)
You can use the following additional orchestration flow shapes in your orchestration design.

Loop. Provides a mechanism for repeating actions—including actions in other shapes—provided
that some condition is met. You set the condition in the form of a Boolean expression by using
Expression Editor.

Parallel Actions. Provides a mechanism to coordinate multiple receive shapes when messages
might arrive in any order. The parallel action shape will wait for all of the receive shapes to
complete before it executes the rest of the orchestration. The parallel action shape does not
support concurrent execution, it executes only one branch at a time. If you are waiting to receive
three messages and do not know or care about the order in which they arrive, you can place a
Receive shape in each of the branches of a Parallel Actions shape. Whichever branch receives a
message first can operate on it, and when the branch completes the orchestration will wait for
the remaining branches to receive and process their messages. All branches merge at the end of
the Parallel Actions shape, and processing does not continue from that point until all previous
actions have been completed.

Suspend. Pauses a running orchestration instance until an administrator explicitly intervenes.
You configure the condition used to suspend an orchestration by using the Expression Editor.
Typically, the purpose is to reflect an error condition that will require attention beyond the scope
of the orchestration. When an orchestration instance is suspended, an error is generated. To
help the administrator diagnose the situation, you can specify a message string to accompany the
error. All state information for the orchestration instance is saved and is then reinstated if and
when the administrator resumes the orchestration instance.

Terminate. Terminates all activities of a running orchestration. You use a Terminate
shape to end the orchestration immediately when an abnormal situation occurs. To help
the administrator diagnose the situation, you can also specify a message string to
accompany the error.
Expression and Exception Shapes
Configure expressions and throw exceptions.
Expression Shape
The Expression shape allows you to enter complex expressions into your orchestration easily
and quickly; however, you cannot use it to enter an arbitrary amount of code. For example, you
can initialize and manipulate the values of your orchestration variables, assign values to dynamic
ports, or make a .NET call to run an external program. You use the Expression Editor to define
the expression.
Throw Exception Shape
You can explicitly throw exceptions in an orchestration by using the Throw Exception shape.
When the throw is performed, the runtime engine will search for the nearest exception handler
that can handle the type of exception being thrown. After a matching exception handler is
found, control is transferred to the first statement of the exception handler. If the search for
matching exception handlers fails, the orchestration halts. Transactions (which will be discussed
in the next module) can help you minimize the impact of such an occurrence.
Nesting Orchestrations
Configure an orchestration to call or start other orchestrations.
Overview
Two shapes that can be used to make your business processes more understandable and easier
to deploy and test are the Call and Start Orchestration shapes. These two shapes let you
effectively nest orchestrations within other orchestrations whether they are transactional or
not.
Call Orchestration Shape
The Call Orchestration shape is used to invoke another nested orchestration synchronously,
which means that the enclosing orchestration waits for the nested orchestration to finish before
continuing.
You can specify parameters that will be passed to the nested orchestration. Parameters can be
messages, variables, port references, role links, or correlation sets. Parameters can be defined
as one way (in or out), or they can also be passed by reference as with a .NET method
parameter. Passed-in port references, role links, and correlation sets all perform in a way similar
to that of self-addressed envelopes, which means that they supply the nested orchestration
information that it can use to send information back to the enclosing orchestration.
Start Orchestration Shape
Similar to the Call Orchestration shape, the Start Orchestration shape can be used to nest other
orchestrations; however, this nesting is asynchronous, which means that the flow of control in
the invoking orchestration proceeds beyond the invocation without waiting for the invoked
orchestration to finish its work.
As with the Call Orchestration shape, you can specify parameters that will be passed to the
called orchestration. The Start Orchestration shape can only take in parameters; it cannot take
out or reference parameters.
Lesson 2: Configuring Orchestrations
Lesson objective:
Configure orchestration expressions, message correlation, and exception handling.
Overview
Before you build an orchestration, you may need to designate specific fields as being
distinguished fields so that the data within a message can be referenced within an orchestration.
When building an orchestration, you can create expressions to make decisions, set delays, make
.NET calls, and test while loop conditions. You can also configure correlation so that incoming
messages can be matched with an instance of a currently running orchestration. Finally, you can
use exception handling to specify the actions that must take place when an error occurs.
Distinguished Fields
Explain the purpose of distinguished fields and the difference between distinguished fields and
promoted properties.
What Are Distinguished Fields?
Distinguished fields are message data of special interest. They are used to make decisions or to
manipulate data in your orchestration. Examples of data manipulation that can be performed by
distinguished fields are accessing and updating instance data.
Using Distinguished Fields
Within an orchestration, the XPath expression relating to any node can be used to read and/or
write values within messages. Promoting a node as a Distinguished field in a schema provides an
easily accessible alias for that node so that lengthy XPath expressions do not have to be typed
repeatedly. Also, distinguished fields provide a performance improvement over using XPath
expressions because the values are pre-fetched as the message is being fed into the
orchestration.
Distinguished fields are limited to unique non-repeating values, and the values are limited to no
more than 255 characters. Once a node has been defined as a distinguished field, simple dotted
notation syntax can be used to reference the node. For example, after promoting the
CompanyName node as a Distinguished field in the PurchaseOrder schema, this node can be
accessed using syntax such as the following to access the value from a message variable named
msgPurchaseOrder:
msgPurchaseOrder.CompanyName
Promoting a Distinguish field is done in the BizTalk Editor in Microsoft Visual Studio® 2010 by
right-clicking the node, pointing to Promote, and then clicking Show Promotions. The resulting
dialog box displays the Schema tree in the left pane and has Distinguished Fields and Property
Fields tabs. On the Distinguished Fields tab, select the node in the schema tree, and then click
Add. The node is added to the Property list with its corresponding XPath listed.
Distinguished Fields vs. Promoted Properties
We have previously discussed promoted properties, which are used by the messaging engine in
routing and tracking processes. Promoted properties are also used for a special kind of routing,
called correlation, which will be discussed later in this module. Promoted properties are
primarily used for routing purposes but can also be accessed in orchestrations by using a
simplified syntax, such as:
msgSalesOrder(AdvWorks.Messaging.PropertySchema.OrderTotal)
In this example, msgSalesOrder is the name of a message variable defined in this orchestration
for a message based on the SalesOrder type in the AdvWorks.Messaging project. The OrderTotal
node has been promoted to the default property schema in that project.
As you can see, the distinguished field syntax provides more direct access to a message node.
The overuse of property promotion can have a negative performance effect, whereas
distinguished properties do not incur additional overhead. For optimal performance, promote
only those properties that are required for routing purposes, and distinguish the node if the
data is required within an orchestration.
Demonstration: Configuring Orchestration Flow
Learn how to promote distinguished fields and then use a distinguished field in a decide shape.
The following demonstration is not dependent upon completion of the previous
demonstrations. This solution provides artifacts and file paths that differ from those
used in the previous demonstrations.
Promote Distinguished Fields
1. In Microsoft Windows Explorer, navigate to
C:\AllFiles\DemoCode\Module9\AdvWorks, and then double-click the AdvWorks.sln
file.
2. In Solution Explorer, in the Messaging project, double-click SalesOrder.xsd to open the
schema.
3. In the SalesOrder schema, right-click <Schema>, and then click Expand Schema Node.
4. Right-click <Schema>, point to Promote, and then click Show Promotions.
5. In the Promote Properties dialog box, click the Property Fields tab, and notice that
OrderType and CustomerName have already been promoted as Property Fields.
6. Click the Distinguished Fields tab, and then in the schema tree view, click Comment,
and then click Add.
7. Repeat step 6 for OrderTotal and then OrderNumber (under the Detail node), and then
click OK.
8. In Solution Explorer, right-click the AdvWorks solution, and then click Build Solution.
Examine a Group Shape
1. In Solution Explorer, in the Processes project, double-click ProcessOrder_Cash.odx.
2. Click the existing Group shape to collapse it, and then click it again to expand it.
Use the Expression Editor
1. Inside the Construct msgSOComplete shape, double-click the Build Complete SO shape.
2. In the BizTalk Expression Editor window, beneath the existing line of code, enter the
following line of code, and then click OK.
msgSalesOrder_Complete.Comment =
“Processing of this order is now complete.”;
Configure a Decision Shape
1. Right-click the area below the Rcv Sales Order receive shape, point to Insert Shape, and
then click Decide.
2. In the Properties window, in the Name box, type Order Size?
3. In the ProcessOrder_Cash orchestration, click the Rule_1 shape, and then in the
Properties window, in the Name box, type Large.
4. In the Properties window, click Expression, and then click the ellipsis (…) button.
5. In the BizTalk Expression Editor, type the following line of code, and then click OK.
msgSalesOrder.OrderTotal > 2000
6. Right-click the placeholder below the Large branch, point to Insert Shape, and then click
Send.
7. Name the Send shape Snd Approval Request, and in the Message list, click
msgSalesOrder.
Configure a Listen Shape
1. Right-click the area below the Snd Approval Request shape, point to Insert Shape, and
then click Listen.
2. Name the Listen shape Listen for Response.
3. Right-click the first placeholder in the left branch of the Listen shape, point to Insert
Shape, and then click Receive.
4. Name the Receive shape Rcv Order Approval, and in the Message list, click
msgApproved.
5. Right-click the first placeholder in the right branch of the Listen shape, point to Insert
Shape, and then click Delay.
6. Name the Delay shape Wait for Approval, then click the Delay property, and then click
the ellipsis (…) button
7. In the BizTalk Expression Editor window, enter the following line of code, and then click
OK.
new System.TimeSpan(0, 0, 30)
This will cause the orchestration to wait 30 seconds for an approval message.
8. Right-click the placeholder beneath the Delay shape, point to Insert Shape, and then
click Suspend.
9. In the Properties window, name the Suspend shape Timed Out, then click the Error
Message property, and then click the ellipsis (…) button, and enter the following line of
code, and then click OK.
System.String.Format(
“Order# {0} did not receive an approval to proceed.”,
msgSalesOrder.Detail.OrderNumber);
Create a Logical Send Port
1. Right-click the left Port Surface, and then click New Configured Port.
2. On the Welcome to the Port Configuration Wizard page of the Port Configuration
Wizard, click Next.
3. On the Port Properties page, in the Name box, type RequestApproval, and then click
Next.
4. On the Select a Port Type page, click Use an existing Port Type, then select
AdvWorks.Processes.SalesOrderType, and then click Next.
5. In the Port direction of communication list, click I’ll always be sending messages on
this port, and then click Next.
6. Click Finish.
7. Drag the green arrow from the Snd Approval Request Send shape to the
RequestApproval send port.
Create a Logical Receive Port
1. Right-click the left Port Surface, and then click New Configured Port.
2. On the Welcome to the Port Configuration Wizard page of the Port Configuration
Wizard, click Next.
3. On the Port Properties page, in the Name box, type ReceiveApproval, and then click
Next.
4. On the Select a Port Type page, click Create a new Port Type, and name it
ApprovalType, and then click Next.
5. In the Port direction of communication list, click I’ll always be receiving messages on
this port, and then click Next.
6. Click Finish.
7. Drag the green arrow from the ReceiveApproval receive port to the Rcv Order Approval
receive shape.
8. Close the ProcessOrder_Cash.odx orchestration, saving your changes.
9. Pause the bt10d-demos virtual machine.
Creating Expressions
Configure expressions by using the Expression Editor.
Using Expressions
The Expression shape enables you to create expressions within an orchestration. Expressions
can be used to add logic and to manipulate and test values. For example, you can initialize and
manipulate the values of your orchestration variables, assign values to dynamic ports and
message context, and make a .NET call to run an external program.
Expressions should not be used to perform high-level orchestration logic, which preferably
would be visible in the orchestration drawing itself. In general, it is easier to understand and
maintain your orchestrations if your Expression shapes contain simple and modular expressions.
Expression Editor
The BizTalk Expression Editor enables you to create expressions to define the capabilities of
various orchestration shapes. Expressions created within the Expression editor are written using
C# syntax. An expression can span multiple lines, but it must end with single semicolon (;). You
can create expressions to make decisions, set delays, and test while loop conditions. For more
information, see “Shapes that Take Expressions” in BizTalk Help.
Only expressions created for the Expression shape can end in a semicolon; no other expression
can. This is because the expression for other shapes is a single Boolean test (the equivalent of
the contents of a set of parentheses in C#). In addition to the standard .NET operators, you can
also use the exists operator to determine if a value is present in a message instance.
Using Expression Editor, you can assign values to messages or message parts in the Message
Assignment shape. You can also use Expression Editor to construct complex Boolean expressions
in the Loop and Decide shapes and set the delay in the Delay shape.
IntelliSense
The BizTalk Expression Editor is a standard Visual Studio text editor, which means that it offers
IntelliSense®. The IntelliSense feature will help guide you in creating expressions—for example,
it can display a list of class members for you when you type in a .NET class name followed by a
period (.).
Correlating Messages
Explain how correlation works and configure correlation sets.
What Is Correlation?
Correlation is a special variation on message routing that matches an incoming message to the
appropriate instance of an orchestration. Often, there may be many instances of a given
orchestration running, and although each of the instances will perform the same actions, they
will do so on different data contained in messages. For example, if your orchestration is
designed to issue a purchase order, receive an invoice, and then send a payment, you must
ensure that the invoice message is received by the orchestration instance from which the
corresponding purchase order was sent. (Imagine ordering a single item and receiving an invoice
for 1,000 items, or vice versa, and you can understand the importance of correlation.) Likewise,
if two related messages are meant to be kept together and sent consecutively, you can use
correlation to ensure that they are received in the proper order by the same instance.
Correlation Sets
Each correlation set is based on a correlation type, which is simply a list of properties. These
properties might be data (found in the message itself) or context properties that describe
system-defined details or transport properties for the message that have no relation to the data
actually being conveyed in the message. In order to use message data for a correlation type, the
nodes must be promoted to make the values accessible to the messaging engine.
You can use a single correlation type in more than one correlation set. If you need to correlate
based on different values for the properties in a correlation type, you must create a new
correlation set, because each correlation set can be initialized only once.
Demonstration: Correlating Messages
Learn how to configure correlation for an orchestration.
Create a Property Field for Correlation
1. Resume the bt10d-demos virtual machine.
2. Open the PropertySchema.xsd schema.
3. Right-click <Schema>, point to Insert Schema Node, and then click Child Field Element.
4. Name the element OrderID.
Promote the OrderNumber in the SalesOrder Schema
1. Open the SalesOrder.xsd schema.
2. Right-click <Schema>, point to Promote, and then click Show Promotions.
3. In the Promote Properties dialog box, click the Property Fields tab.
4. In the schema tree view, click OrderNumber, and then click Add.
5. In the Property column, in the drop-down list, click OrderID, then click OK.
Promote the ReferenceNumber in the OrderApproval Schema
1. Open the OrderApproval.xsd schema.
2. Right-click <Schema>, point to Promote, and then click Show Promotions.
3. In the Promote Properties dialog box, click the Property Fields tab.
4. In the schema tree view, click ReferenceNumber, and then click Add.
5. In the Property column, in the drop-down list, click OrderID, then click OK.
6. Right-click the Messaging project, then click Build.
Create a Correlation Type
1. In Orchestration View, for the ProcessOrder_Cash.odx orchestration, expand Types,
right-click Correlation Types, and then click New Correlation Type.
2. In the Correlation Properties window, in the left pane, expand
AdvWorks.Messaging.PropertySchema, click OrderID, click Add, and then click OK.
3. In the Correlation Type Properties window, change the Identifier to
ManualApprovalCorrType.
Create a Correlation Set
1. In Orchestration View, right-click Correlation Sets, and then click New Correlation Set.
2. In the Properties window, in the Identifier box, type ManualApprovalCorrSet, and then
in the Correlation Type list, click AdvWorks.Processes.ManualApprovalCorrType.
Configure Correlation for the Orchestration
1. Click the Snd Approval Request shape, and then in the Properties window, in the
Initializing Correlation Sets list, click ManualApprovalCorrSet.
2. Click the Rcv Order Approval shape, and then in the Properties window, in the
Following Correlation Sets list, click ManualApprovalCorrSet.
3. Close all open windows, and shut down the virtual machine.
Handling Exceptions
Explain how exceptions are generated and how the BizTalk Exception Handler works.
Exceptions
Exceptions are raised by the orchestration engine when an error occurs in the orchestration.
Microsoft BizTalk Server provides various mechanisms for throwing and handling exceptions.
How Exceptions Are Generated
Exceptions can be generated in an orchestration in any of the following ways:







When the Throw Exception shape is explicitly used.
When a time-out in an atomic or long-running transaction occurs.
When some other transaction failure occurs. (The run-time engine throws a systemdefined message for these exceptions.)
When calls to external assemblies are made and result in an exception. (Common
language runtime classes that are called can throw exceptions.)
When a system exception (such as a persistence failure, another. NET or system
exception, or a data-conversion error) is raised.
When a sibling branch in a surrounding scope halts execution. (A predefined system
exception is thrown.)
When the receipt of an external message indicates a fault.
Exception Handler
When an exception occurs in a scope, each logical thread of execution in that scope stops. The
run-time engine attempts to locate an exception handler for the appropriate exception type. If it
succeeds in locating an exception handler that matches either the specific exception type or one
of its base types, control passes to that handler, and the exception code runs.
Each scope shape within an orchestration may have one or more exception handler blocks
appended to it. The relative cost of catching and handling an exception is high, so as with .NET
exception handling, you should reduce the likelihood of exceptions occurring whenever
possible. Don’t use exception handlers to catch common conditions; use a decide shape instead.
For example, it’s always easier to determine if you are going to divide by zero than to catch a
divide-by-zero exception.
Each exception block can contain zero or more orchestration shapes, which act exactly as they
do in an orchestration. As a result, anything that can be done in an orchestration can be undone
with an exception handler. In some situations, you may want to catch an exception and not do
anything as a result. This will prevent the exception from being passed up to the next scope
looking for an exception handler.
The arrangement of exception handlers is important in situations in which multiple exceptions
blocks exist. The first block that can catch the exception will catch it and execute without
evaluating other handlers. Place the most specific exceptions first working toward more general
exceptions, the most general of which is the General Exception.
Note: The process of adding and configuring exception handing for an orchestration is covered
in detail in the Module 10 Lab.
Lab: Automating Business Processes
Time estimated: 60 minutes
Scenario
BizTalk orchestrations can be used to automate business decisions and other processes. In this
lab, you will create a new BizTalk orchestration that will process credit sales orders.
Start the Virtual Machine
Procedure List
1. If the Server Manager window is not already open, click on the Server Manager icon
located in the task bar next to the Start button.
2. Expand Roles, Hyper-V, Hyper-V Manager. The last node to appear displays the
machine name. Click on it to see the list of virtual machines available.
3. Double-click the virtual machine bt10d-09 to open a Virtual Machine Connection
window.
4. Click on the Action menu in the Virtual Machine Connection window and choose Start.
5. Once the virtual machine starts, press CTRL+ALT+END.
6. Log on using the user name Administrator and the password pass@word1.
7. At the Windows Activation prompt, click Ask Me Later, then click OK.
Ensure that the BizTalk Services are started
Procedure List
1. In Windows Explorer, navigate to C:\AllFiles.
2. Double click on startBtServices.cmd.
3. When prompted, press any key to close the command-line window.
Exercise 1: Examine an Existing Project
Overview
In upcoming labs, you will add functionality to the LoanApproval project that will evaluate and
approve loans. Initially, this project contains several artifacts that are required for this lab. In
this exercise, you will examine the FinalLoanDocument schema and the
SalesOrder_To_FinalLoanDocument map to familiarize yourself with their design.
Examine the LoanApproval Project
Procedure List
1. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab9\AdvWorks and then doubleclick AdvWorks.sln.
2. In Solution Explorer, double-click FinalLoanDocument.xsd.
3. In the FinalLoanDocument schema, right-click <Schema>, and then click Expand Schema
Node.
4. Right-click <Schema>, point to Promote, and then click Show Promotions.
Notice the Distinguished Fields of the FinalLoanDocument schema.
5. Click the Property Fields tab.
Notice the Promoted Properties of the FinalLoanDocument schema.
6. Click OK to close the Promote Properties dialog box.
7. Close the FinalLoanDocument schema, and then click Yes to save changes.
8. In Solution Explorer, double-click SalesOrder_To_FinalLoan.btm.
Examine the SalesOrder_To_FinalLoan map.
9. Close the SalesOrder_To_FinalLoan map.
Exercise 2: Promote Distinguished Fields
Overview
Specifying a field in a schema as distinguished enables you to easily access the field from within
an orchestration for decision-making and data-manipulation purposes. In this exercise, you will
distinguish several fields that will be used in the orchestration.
Promote Three Distinguished Fields
Procedure List
1. In Solution Explorer, in the Messaging project, double-click SalesOrder.xsd.
2. In the SalesOrder schema, right-click <Schema>, and then click Expand Schema Node.
3. Right-click <Schema>, point to Promote, and then click Show Promotions.
4. In the Promote Properties dialog box, click Comment, and then click Add.
5. Repeat step 4 for OrderTotal and OrderType, and then click OK.
6. On the File menu, click Save All, and then close the SalesOrder schema.
Exercise 3: Create a New Orchestration
Overview
Adventure Works offers two types of financing in their stores. Loans for more than $1,000 are
sent to Woodgrove Bank, while loans of $1,000 or less are managed by the Adventure Works
finance department. In this exercise, you will create an orchestration that will process the credit
sales orders and determine the loan type.
Create the ProcessOrder_Credit Orchestration
Procedure List
1. In Solution Explorer, expand Processes, right-click ProcessOrder_Cash.odx, and then
click Copy.
2. Right-click Processes, and then click Paste.
3. Click Copy of ProcessOrder_Cash.odx. In the Properties window, in the File Name box,
type ProcessOrder_Credit.odx, and then press ENTER.
4. In Solution Explorer, double-click ProcessOrder_Credit.odx.
5. In the Properties window, in the Typename box, type ProcessOrder_Credit.
6. In Orchestration View, right-click Messages, and then click New Message.
7. In the Message_1 Properties window, in the Identifier box, type msgFinalLoan.
8. In the Message Type list, under Schemas, click <Select from referenced assembly>.
9. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.LoanApproval, in
the right pane, click FinalLoanDocument, and then click OK.
10. In the ProcessOrder_Credit orchestration, right-click the arrow immediately below the
Sales Order receive shape, point to Insert Shape, and then click Transform.
11. Click the ConstructMessage_1 shape, and then in the Properties window, in the Name
box, type Construct msgFinalLoan.
12. In the Messages Constructed list, click msgFinalLoan.
13. Click the Transform_1 shape, and then in the Properties window, in the Name box, type
Map to Final Loan.
14. In the Properties window, click Map Name, and then click the ellipsis (…) button.
15. In the Transform Configuration dialog box, click Existing Map, and then in the Fully
Qualified Map Name list, click <Select from referenced assembly>.
16. In the Select Artifact Type dialog box, in the left pane, click AdvWorks.LoanApproval, in
the right pane, click SalesOrder_to_FinalLoan, and then click OK.
17. In the Transform Configuration window, click Source, and then in the Variable Name
list, click msgSalesOrder.
18. Click Destination. In the Variable Name list, click msgFinalLoan, and then click OK.
19. Right-click the arrow below the Construct msgFinalLoan shape, point to Insert Shape,
and then click Decide.
20. In the Properties window, in the Name box, type Determine Lender.
21. In the ProcessOrder_Credit orchestration, click the Rule_1 shape, and then in the
Properties window, in the Name box, type Large.
22. In the Properties window, click Expression, and then click the ellipsis (…) button.
23. In the BizTalk Expression Editor, in the text box, type msgFinalLoan.Loan.Amount>1000,
and then click OK.
24. Right-click the placeholder below the Large branch, point to Insert Shape, and then click
Send.
25. Configure Send_1 with the properties shown in the following table.
Property
Setting
Name
Notify Bank
Message
msgFinalLoan
You will make the necessary changes to the Else branch in a later lab.
Exercise 4: Create Orchestration Ports
Overview
The ports in this orchestration ports are configured as late bound (Specify Later), so they must
be bound to a physical port after the assembly is deployed. Using late binding separates the
design of an orchestration and its implementation. In this exercise, you will add a new late
bound orchestration port and reconfigure the existing ports to use late binding.
Reconfigure Port Types
Procedure List
1. In Orchestration View, expand Types, Port Types, right-click SalesOrderType, and then
click Delete.
2. Right-click RestockType, and then click Delete.
Since these port types are defined in the ProcessOrder_Cash orchestration, they
cannot be defined in this orchestration, too. You must delete the port types from this
list and then reconfigure the ports to use the existing port types from the
ProcessOrder_Cash orchestration.
3. On the left Port Surface, right-click the SalesOrder port, and then click Configure Port.
4. On the Welcome to the Port Configuration Wizard page, click Next.
5. On the Port Properties page, click Next.
6. On the Select a Port Type page, click Use an existing Port Type, click
AdvWorks.Processes.SalesOrderType, and then click Next.
7. On the Port Binding page, click Next, and then click Finish.
8. Repeat steps 3–7 for the SO_Complete port.
9. Right-click the Restock port, and then click Configure Port.
10. On the Welcome to the Port Configuration Wizard page, click Next.
11. On the Port Properties page, click Next.
12. On the Select a Port Type page, click Use an existing Port Type, click
AdvWorks.Processes.RestockType, and then click Next.
13. On the Port Binding page, click Next, and then click Finish.
Create a Send Port
Procedure List
1. Right-click the right Port Surface, and then click New Configured Port.
2. On the Welcome to the Port Configuration Wizard page of the Port Configuration
Wizard, click Next.
3. On the Port Properties page, in the Name box, type BankNotification, and then click
Next.
4. On the Select a Port Type page, in the Port Type Name box, type BankNotifyType, and
then click Next.
5. In the Port direction of communication list, click I’ll always be sending messages on
this port, and then click Next.
6. On the Completing the Port Wizard page, click Finish.
7. Drag the green arrow from Notify Bank send shape to the BankNotification send port.
8. In the BankNotification send port, click Operation_1, and then in the Identifier box of
the Properties window, type NotifyLender.
9. In the BankNotification send port, click Request, and then in the Name box of the
Properties window, type msgFinalLoan.
Create Filter Expressions for Orchestrations
Procedure List
1. In Solution Explorer, double-click ProcessOrder_Cash.odx.
2. In the ProcessOrder_Cash orchestration, click the Sales Order receive shape, in the
Properties window, click Filter Expression, and then click the ellipsis (…) button.
3. In the Property list, click AdvWorks.Messaging.PropertySchema.OrderType, in the
Value box, type “CASH” (include the quotation marks), and then click OK.
4. On the File menu, click Save All, and then close the ProcessOrder_Cash orchestration.
5. In the ProcessOrder_Credit orchestration, click the Sales Order receive shape, in the
Properties window, click Filter Expression, and then click the ellipsis (…) button.
6. In the Property list, click AdvWorks.Messaging.PropertySchema.OrderType, in the
Value box, type “CRED” (include the quotation marks), and then click OK.
7. On the File menu, click Save All, and then close the ProcessOrder_Credit orchestration.
Exercise 5: Build, Deploy, and Test the BizTalk Application
Overview
When you test the application, you will submit both cash and credit orders. The cash orders will
be processed by the ProcessOrders_Cash orchestration, and the credit orders will be processed
by the ProcessOrders_Credit orchestration. Credit sales orders over $1,000 will result in a bank
notification message that is sent to Woodgrove Bank. In this exercise, you will deploy and test
the application.
Test the Application
Procedure List
1. In Solution Explorer, right-click Messaging, and then click Build.
2. Right-click Solution ‘AdvWorks’, and then click Project Build Order.
Notice the order in which the projects must be built. The Project Dependencies dialog
box can be used to reorder these builds. If you try to build or deploy the Processes
project, the Messaging and LoanApproval projects will automatically build and/or
deploy.
3. Click OK to close the Project Dependencies dialog box.
4. In Solution Explorer, right-click Processes, and then click Deploy.
5. In the Output window, notice that all three projects were built and deployed.
6. On the Start menu, point to All Programs, then point to Microsoft BizTalk Server 2010,
and then click BizTalk Server Administration.
7. In BizTalk Server Administration Console, expand BizTalk Server Administration, BizTalk
Group, Applications, AdventureWorks.
8. Right-click AdventureWorks, and then click Configure.
9. In the Configure Application dialog box, click ProcessOrder_Cash, and then configure
the settings using the information in the following table.
Property
Settings
Host
BizTalkServerApplication
SalesOrder
SalesOrder
Restock
RestockFILE
SO_Complete
CompleteFILE
In the previous lab, this orchestration was configured with “early binding,” meaning
that the physical ports were automatically created and bound to the logical ports
when the assembly was deployed. In this lab, you are using late binding, so the
logical ports must be bound to the physical ports manually.
10. In the Configure Application dialog box, click ProcessOrder_Credit, configure the
settings using the information in the following table, and then click OK.
Property
Setting
Host
BizTalkServerApplication
SalesOrder
SalesOrder
Restock
RestockFILE
SO_Complete
CompleteFILE
BankNotification
BankNotifyFILE
Both orchestrations use the SalesOrder receive port. The filter expressions you
configured on the receive shapes in each orchestration will prevent an orchestration
from getting any message it shouldn’t.
11. In the BizTalk Server Administration Console, right-click AdventureWorks, click Start,
and then in the Start ‘AdventureWorks’ Application dialog box, click Start.
12. In Windows Explorer, navigate to C:\AllFiles\LabFiles\Lab9, and then copy all four XML
files to the SalesOrderIN folder.
It may take a moment for the messages to be processed and moved from the
SalesOrderIN folder.
13. Open the OUT folder, and then examine each of the messages.
Notice that the Cash and Restock orders have been processed and that the Credit
order over $1000 has a BankNotify message.
14. Close all open windows.
Download