1. Problem
Within a BizTalk orchestration, you would like to reuse common process logic across BizTalk processes.
2. Solution
Within a BizTalk orchestration,
you can call or start other orchestrations without sending a message
outside an orchestration's context. BizTalk orchestrations can function
as traditional functions, calling one another synchronously or
asynchronously. Using the Call Orchestration shape allows a parent
orchestration to call a child orchestration with a set of parameters and
receive output back (synchronous). Using the Start Orchestration shape
allows a parent orchestration to call a child orchestration with any set
of parameters and move on, independent of receiving a result back
(asynchronous).
As an example, assume that you would like to synchronously call an orchestration to perform a validation routine on a message.
Open the BizTalk project that contains the orchestration that you would like to perform the Call Orchestration functionality.
Drag a Call Orchestration shape from the toolbox onto your design surface.
Click
the exclamation mark (tool tip) on the shape. Select No Called
Orchestration - Click to Configure. The Call Orchestration Configuration
dialog box appears.
In the Call Orchestration Configuration dialog box, select the orchestration you wish to call, as shown in Figure 1.
In this dialog box, you can also select parameters that can be passed
by an orchestration. Parameters are passed in the form of .NET
variables. Only orchestration types that have Activation set to False—that
is, only orchestrations that are invoked from another process—will be
available for selection. In this instance, this is the calling
orchestration rather than message instantiation.
Click OK to complete the Call Orchestration shape configuration.
3. How It Works
Orchestration
shapes in the BizTalk Orchestration Designer allow for the calling of
other orchestrations synchronously or asynchronously. The choice of
shape depends on the scenario and design requirements specified for the
operating solution.
Calling an
orchestration synchronously gives you the ability to nest functionality,
similar to calling a method synchronously in any programming language.
Calling an orchestration asynchronously allows an orchestration's
functionality to be abstracted and performed independently without
creating dependencies on the calling and invoking orchestration process.
In addition to calling an
orchestration, you can optionally pass parameters to the calling
orchestration. Parameters can be used to complement or aid in message
processing without the need for custom code development to construct
process-centric message context logic. To achieve this within a BizTalk
orchestration, parameters are defined in the form of .NET BizTalk type
variables. For example, messages, variables, and correlation sets are
all BizTalk type variables eligible to be passed with the calling
orchestration. Figure 2
shows the configuration of a callable orchestration (note that there is
no Receive shape required) with a single input parameter.