BEPL with BizTalk
Overview
BizTalk Server is part of Microsoft's Windows Server System family of products that enable you to integrate systems, employees, and trading partners. It is an integration server product (Middleware) used to connect different applications, systems, or business processes within an organization (EAI) or between organizations (B2B). It is also be used to aggregate services to build a Service-Oriented Architecture (SOA).
Content-Based Routing (CBR) where messages can be routed based on the values of certain fields inside the message
Support for BPEL4WS
Support for WSDL
Support for XSD
Support for XSLT
A Health and Activity Tracking (HAT) tool for tracking and debugging of Orchestrations and messages
A Business Rules Engine for abstracting business rules from the business process
Business Activity Monitoring for real-time monitoring of business process in the production environment
Business Activity Services including Trading Partner Management for integration with other business processes
Human Workflow Services for workflow systems involving human intervention, such as approvals, data entry, and collaborations
Support for BPEL and XLANG/s
BizTalk supports BPEL as a business process exchange format, to exchange the business process definition with other vendors. BizTalk does not natively execute BPEL, but can export business processes to BPEL and also import external BPEL files that define business processes.
In BizTalk, the business process is built visually using the Orchestration Designer inside Visual Studio and is internally stored and represented using XLANG/s.
XLANG/s is Microsoft's proprietary language for defining business processes in BizTalk Server 2004. It is an improved version of XLANG (used in earlier versions of BizTalk), with support for the .NET framework and for invoking .NET components. It is not mandatory for a developer to learn the underlying XLANG/s to build business processes as the Orchestration Designer automatically generates it.
While BPEL is platform neutral by design, XLANG/s is very specific to BizTalk and the .NET platform and as such is able to provide advanced functionalities and a broader range of services than BPEL. However, this also means that if you plan to export business processes to BPEL, you should carefully avoid using features specific to BizTalk and XLANG/s, such as message transformation using maps or calling .NET components from within an Orchestration.
BizTalk Orchestration Shape | BEPL Tag |
Send shape | <invoke> or <reply> |
Receive shape | <receive> |
<receive> | Port |
Port | <partnerLinks>, <partnerLink> |
<partnerLinks>, <partnerLink> | Role Link |
Role Link | <partnerLinkType>, <role> |
<partnerLinkType>, <role> | Message Assignment shape |
Message Assignment shape | <assign>, <copy>, <from>, <to> |
<assign>, <copy>, <from>, <to> | Decide shape |
Decide shape | <switch>, <case>, <otherwise> |
<switch>, <case>, <otherwise> | Delay shape |
Delay shape | <wait> |
<wait> | Listen shape |
Listen shape | <pick>, <onMessage>, <onAlarm> |
<pick>, <onMessage>, <onAlarm> | Parallel Actions shape |
Parallel Actions shape | <flow> |
<flow> | Loop shape |
Loop shape | <while> |
<while> | Scope shape |
Scope shape | <scope> |
<scope> | Throw Exception shape |
Throw Exception shape | <throw> |
<throw> | Compensate shape |
Compensate shape | <compensate> |
<compensate> | Suspend shape |
Suspend shape | Not supported in BPEL |
Not supported in BPEL | Call Orchestration shape |
Call Orchestration shape | Not supported in BPEL |
Not supported in BPEL | 0 |
Start Orchestration shape | |
Start Orchestration shape | Not supported in BPEL |
Not supported in BPEL | Call Rules shape |
Call Rules shape | Not supported in BPEL |
Not supported in BPEL | Transform shape |
Transform shape | Not supported in BPEL |
Not supported in BPEL | Terminate shape |
Terminate shape | <terminate> |
<terminate> | Compensation Block |
Compensation Block | <compensationHandler> |
<compensationHandler> | Exception Handler |
Exception Handler | <faultHandler>, <catch>, <catchAll> |
<faultHandler>, <catch>, <catchAll> | Correlation |
Correlation | <correlation>, <correlations>, <correlationSets>, <correlationSet> |
Exporting Orchestration to BPEL
In the last section we saw how to build an Orchestration in BizTalk. In this section we will export the same to BPEL.
To export the Orchestration to BPEL, we have to do the following:
Keeping the Orchestration Designer selected in the foreground, bring up the properties window such that it displays the Orchestration properties.
You will see that the Module Exportable property is set to False. Setting this property to true will make two other properties visible in the properties window (Module XML Target Namespace and Orchestration Exportable).
Set a value for Module XML Target Namespace such as http://packtpub.com/bpel/example and set the Orchestration Exportable to True. This will make another property visible, called the Orchestration XML Target Namespace, shown in the figure below.
Set a value for Orchestration XML Target Namespace and you are all set to export the Orchestration to BPEL.
In the Solution Explorer window right-click on the Orchestration file (InsuranceSelectionProcess.odx) and select Export to BPEL.
Importing BPEL Processes into BizTalk
Importing BPEL processes into BizTalk is quite easy. BizTalk provides a separate project template called the BizTalk Server BPEL Import Project, which will bring up a wizard to take you through the BPEL import procedure step by step. However, there are a few things you need to take care of before importing business processes:
Ensure that the Name property of the WSDL definition node and that of the BPEL process node are not the same.
Do not use any XLANG/s reserved words in your BPEL.
Use only simple types predefined in XSD.
To import the .bpel and the .wsdl files into BizTalk. Here are the step-by-step instructions:
Open a new BizTalk Server BPEL Import Project in Visual Studio .NET and name it AsyncTravelProcessBPELImport as shown overleaf.
Click OK to bring up the BPEL Import Wizard shown below.
Click Next, and then Finish.
After importing the travel process example, you can see in the Solution Explorer of Visual Studio that the wizard has created four orchestration (.odx) files and two schema (.xsd) files shown below:
The wizard breaks down each .wsdl file into a schema file (.xsd) that contains the schema definition and an orchestration file (.odx) that contains the other things like Port Types, Message Types, and Partner Link Types (known as Role Link Types in BizTalk). This orchestration file does not contain any business process logic and is only used to define the types.
The .bpel file is converted into an orchestration file (.odx) that contains the actual business process logic and declarations for things like Partner Links (Ports and Role Links in BizTalk) and Variables (Messages in BizTalk).
Comparing BizTalk Orchestration Constructs with BPEL
Receive and Send Shapes (<receive>, <invoke>, <reply>)
Messages are received and sent to the ports (partnerLinks) within the BizTalk Orchestration using the Receive and Send shapes. These are equivalent to the <receive>, <reply>, or <invoke> keywords of BPEL. Note that the same Send shape is used to send messages for both One-Way (Asynchronous <invoke>) and Request-Response (Synchronous <reply>) calls.
Port and Role Link Shapes (<partnerLink>, partnerLinkType>, <role>)
Ports and Role Links are the endpoints for messages entering or exiting the Orchestration. They are similar to partner links in BPEL. Configuring the ports includes setting the PortType, Communication Direction (send or receive), Communication Pattern (One-Way or Request-Response), Delivery Notification, and Binding to the physical ports, among other things. When you drop a Port shape or a Role Link shape onto the side panels of the Orchestration Designer surface, the Port Configuration Wizard pops up and assists you in configuring the ports. Role Link is used to group together multiple PortTypes, similar to <partnerLinkType>.
Expression and Message Assignment Shapes (<assign>, <copy>, <from>, <to>)
Expression and Message Assignment shapes, as the name suggests, are used to implement business logic that contains expressions, loops, conditions, and assignments. It is possible to use XPath and XLANG/s within these shapes and also to call any external .NET components by defining and instantiating a variable of the particular .NET type.
Decide Shape (<switch>, <case>, <otherwise>)
A Decide shape is used for conditional branching. It is similar to an IF/THEN/ELSE/ELSIF programming construct or the <switch>, <case>, and <otherwise> constructs of BPEL. It will always have a minimum of two branches. Each branch (other than the Else branch) will have a Rule shape containing the condition expression to be evaluated. The condition expression of each branch is evaluated and if it satisfies the condition, that branch is executed; otherwise it will evaluate the condition of the next branch (if available) and so on. If none of them satisfy the condition the else branch is executed.
Delay Shape (<wait>)
The Delay shape is equivalent to the <wait> activity of BPEL. It is used to delay the execution of the process for a specific length of time (specified by the System.TimeSpan class) or until a particular time or date is reached (specified by the 310 System.DateTime class).
Parallel Actions Shape (<flow>)
The Parallel Actions shape is used to simultaneously execute multiple actions. It is similar to the <flow> activity of BPEL. It is possible to have many parallel branches and the process will wait till all the branches have completed before proceeding further.
Loop Shape (<while>)
The Loop shape is used to iterate through a set of actions as long as the Boolean condition evaluates to True. This is equivalent to the <while> activity of BPEL.
Suspend Shape
A Suspend shape is used to stop a running Orchestration and save its state such that it is possible for the administrator to resume the Orchestration instance. You use the Suspend shape if your Orchestration reaches a condition that is beyond the capabilities of the Orchestration, such that you would rather allow an administrator to look into it and resume the operations based on the administrator's decision. When an Orchestration is suspended an error is logged and it is possible to specify a string containing a brief description along with the error message to help the administrator diagnose the problem. This activity is not available in BPEL.
Terminate Shape (<terminate>)
A Terminate shape is used to abruptly stop all activities of a running Orchestration. This is equivalent to the <terminate> activity of BPEL. When an Orchestration is terminated an error is logged and it is possible to specify a string containing a brief description along with the error message to help the administrator diagnose the problem.
Integration with Web Services
BizTalk Server 2004 has native support for web services. It has a built-in SOAP adapter to directly communicate with web services. An Orchestration can consume web services by adding a web reference of the external services' provider from within the Visual Studio .NET environment. It is also possible to easily expose business processes as web services using a tool called Web Services Publishing Wizard, so that they can be used by external systems.
I recommend the book "Business Processes Execution Language for Web Services" to learn more exciting futures of BizTalk and it's compatibility with BPEL.Bibliography
Books:
Business Processes Execution Language for Web Services
Web References:
http://www.oasis-open.org/committees/download.php/2046/BPEL%20V1-1%20May%205%202003%20Final.pdf
http://dev2dev.bea.com/webservices/BPEL4WS.html
http://www.ibm.com/developerworks/library/specification/ws-bpel/
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbizspec/html/bpel1-1.asp