BPEL4WS, Contract-First and BizTalk Server 2004
In the past days I have been reading a lot of post about the Contract First approach related with BizTalk. In particular Aaron Skonnard posts a nice comment about the interrelation between BizTalk, SOA and Contract-First concepts.
In this post I want to explain how to use the Contract-First approach using BPEL4WS Standard and the BPEL Import Wizard provided by BizTalk Server 2004.
Contract-First.
BizTalk Server 2004 is one of the most SOA oriented product that Microsoft has in this moment. The different engine in BizTalk implement some of the most basic SOA concepts and makes so easy the integration between BizTalk and Web Services using solutions like the Web Services or WSE adapters or the BPEL4WS tools.
Orchestrations typically sends-receives well-defined messages in a locations using some transport protocols. Some of these messages can be the XML representation of .NET types and in consequence aren’t truly interoperable with heterogeneous systems. In the other hand in some scenarios the orchestrations can be exposed as Web Services, using SOAP-based adapters, to interoperate with potential clients using the Web Service facilities. In these scenarios the activation ports are being described using WSDL.
Some of the BizTalk messaging engine components (ex: PortTypes, Ports, Operations, messages) have an equivalent in WSDL. This fact makes so easy to obtain a WSDL representation of these components. This is the approach followed by some tools like the Web Service-WSE Publishing Wizard and even the UDDI Publishing Wizard (that I provide as part of the Bts 2004 Competition) use WSDL to describe the PortTypes.
As Aaron exposes, contract-first must be almost native to BizTalk developers since they have to think in messages as one of the first components of any application. Thinking in contract-first makes so flexible the interoperability of BizTalk applications with heterogeneous systems. Is particularly important think in contract-first when we want to describe components of our orchestration using WSDL as description language. In these case would be fantastic if we first design the WSDL and then uses this WSDL to generate the orchestration components. Well, in BizTalk Server 2004 this solution is possible using the support that BizTalk provides to BPEL4WS.
BPEL4WS and WSDL.
In BPEL4WS a business process defines how to coordinate the interactions between a process instance and its partners. All the partners that interact as part of the process are modeled as WSDL services. A BPEL4WS process also is modeled using the WSDL model of separation between the abstract message contents used by the business process and deployment information (messages and PortType versus binding and address information). Typically a BPEL4WS process uses some .wsdl and .bpel files.
BizTalk Server 2004 provides support for BPEL4WS 1.1 fundamentally using the BPEL Import-Export wizards. Using these tools we can export some types of orchestrations to BPEL4WS (.bpel and .wsdl file are generated) and also import .bpel and .wsdl files to create a BizTalk orchestration.
BPEL4WS Import Wizard.
We can use this wizard to generate BizTalk orchestrations based on BPEL4WS process described in .bpel and .wsdl files. The WSDL files are mapped to the type section of the orchestration (PortTypes, RoleLinkTypes, MessageTypes) and the BPEL files contains the process logic. The great new is that BPEL files aren’t mandatory. That is, we can only import WSDL files and, of course, generate only the type section of the orchestration. This is an interesting solution to follow when we think in contract-first. Consider the following WSDL
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://www.openuri.org/" xmlns:q1="http://ContractFirstSamples.org/SimpleSample" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" targetNamespace="http://www.openuri.org/" name="MyServiceTypes"> <types> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://ContractFirstSamples.org/SimpleSample"> <xs:element name="Result" type="xs:string"/> <xs:element name="Root"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="param1" type="xs:string"/> <xs:element name="param2" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> </types> <message name="FirstMsgIn"> <part name="MainPart" element="q1:Root"/> </message> <message name="FirstMsgOut"> <part name="MainPart" element="q1:Result"/> </message> <portType name="SimplePortType"> <operation name="MainOp"> <input message="tns:FirstMsgIn"/> <output message="tns:FirstMsgOut"/> </operation> </portType> <plnk:partnerLinkType name="SimplePortType"> <plnk:role name="portRole"> <plnk:portType name="tns:SimplePortType"/> </plnk:role> </plnk:partnerLinkType> </definitions> |
This is a simple WSDL file without a binding and service section and with some BPEL4WS extensions. This WSDL describes a PortType that has a request-response simple operation.
This WSDL can be imported to BizTalk and the corresponding PortTypes and MessageTypes will be generated. The partnerLinkTypes are directly mapped to Role Link Types in BizTalk but they aren’t required in the WSDL; that is, we can import a WSDL without any BPEL4WS extension. We can also generates the ports if we use the BPEL file.
BPEL4WS import wizard is one of the tools to consider when we want to think in contract-first in BizTalk Server 2004. This tool makes possible to design the description of our process facilitating the interoperability with heterogeneous systems.