Introduction to WS-BPEL

download report

Transcript Introduction to WS-BPEL

Introduction to WS-BPEL and WSO2 BPS

Kasun Indrasiri

Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2 Inc.

May 2013


• • • • What is a Business Process / WS-BPEL WSO2 Business Process Server Introduction to BPEL Developing Business Processes with WSO2 Developer Studio

Business Process

• • Business process is a set of logically related activities These activities are performed in a predefined order to achieve a business goal

Example process

Orchestration vs. Choreography

• Orchestration – Business process with central coordinator – WS-BPEL • Choreography – Business collaboration


• • • • • Business Process Execution Language An Oasis standard XML based language for service composition BPEL defines xml based grammar for describing the logic to coordinate and control interactions between Web Services Create, Consume and Aggregate services

Why use WS-BPEL

• • • • • Increase efficiency of business – No need to worry about the coordination of the process Portable business processes – Built on top of standard compliant web services infrastructure Industry wide language for implementing business processes – Common skill set Native support for long running processes – Execute asynchronous processes that takes days to complete Managed execution

WSO2 Business Process Server

• • • • Executes business processes written using WS-BPEL standard Powered by Apache ODE ( ) WS-Human Tasks and BPEL4People Provides a Management Console to – View and Manage Processes / Human Tasks – – View and Manage Instances / Tasks Configure QOS …

Introduction to WS-BPEL

Want to implement a BPEL Process ?

• You should have some knowledge on – XML – – XML Namespaces XML Schema – – WSDL XPath – XSLT

Structure of a WSDL

• • • • • + + +

BPEL Document Structure


BPEL Process






• • Characterizes the conversational relationship between two services Define the roles played by each of the services in the conversation


Buyer Invoke Seller Seller Buyer Invoke Seller Seller Process Send response to Buyer’s Callback Async Partner Service Process Sync Partner Service


• • Define the relationship between the participating web services ( partners ) and the business process – myrole “business process’s role” – partnerRole “partner service’s role” Associates interfaces (WSDL ports) with roles, using PartnerLinkTypes

Partner Links

Partner Link

• • Partner Link Associates with a partner link type


” partnerLinkType=“ BuyerSellerLink ” myRole=“


” partnerRole=“


”/> Defines which role should be played by the process itself and the partner service


• • • Variables used by the process to keep the state Statically typed via – WSDL Message Types – XML Schema Types – XML Schema elements Variables can be “global” to the process or “local” to the scope


• Assigning values to variables – When message is received from a partner – – Manipulate variables inside activity Require knowledge about Xpath , XSLT


• • • Activities perform the process logic Basic Activities – describe elemental steps in the process behavior Structured Activities – control-flow logic – may contain other basic or structured activities

Basic Activities

• • • • • • •

Receive Reply Invoke Assign Empty Compensate Catch

• • •

Throw Rethrow Exit


• • • • Receive messages from an external party – Could be an external partner or the initiator of the business process Acts as the entry point to the process. Associated with – PartnerLink with MyRole – – WSDL operation Variable for the incoming message createInstance=“yes” to create a new process instance. Otherwise, the message will be consumed by an already running process instance


• • • Sends the response back to the client Always relates to a “receive” activity – – Associated with Same PartnerLink for the “receive” Same operation for the “receive” – Variable for the output message


• • Used to consume (invoke) partner services Associated with – PartnerLink with at least a “partnerRole” – WSDL operation of the partner service – – Input variable Output variable, if the operation is request-response


• Used to manipulate variables

• • • •

Initializing Variables

Variables contain a piece of XML Manipulated using XPath XPath is evaluated on XML A variable should be initialized before copying values to the internal elements.

Expected Content

• • • echoRequest= HelloWorld First we should initialize the variable ‘echoRequest’ before copying the string value “HelloWorld” to it. $echoRequest/p:echoString/in

Structured Activities

• • • • • • • • • • Sequence While Pick Flow Scope If ForEach RepeatUntil Compensate Link


• • • • Used to define a set of activities to be executed in a strict ordered sequence Can contain both basic and structured activities nested to arbitrary depth standard-attributes>


activity+ Contained activities are executed in the order they are defined Completes when the last activity has completed



• • • • Used to define a set of activities that will execute concurrently Further allows synchronization of dependencies between activities – When one activity finishes, another activity starts Directly nested activities are started concurrently as soon as the flow activity is started Flow activity completes when all nested activities complete



• Used to express a service of alternative choices of which exactly one is executed – Primary conditional branch specified by condition element – followed by • Unlimited number of elseif branches – Each with its own condition expression • One else branch



• Looping executes a subset of the process multiple times in a controlled manner – ForEach – repeatUntil – while





• Waits for the occurrence of exactly one event from a set of events.


• • Used to have the process wait until one of a set of events is triggered – Message events via onMessage element – Alarm events via onAlarm element Can be used to initiate a process instance – If createInstance=“yes” , a new process instance is create upon the reception of one of a set of possible messages – Each on message is equivalent to a receive activity with the createInstance=“yes” – No alarms are permitted in the case


• • Used to group activities into logically organized sections – Encapsulates a possibly compensatable, recoverable unit of work Provide processing context for – Variables – – PartnerLinks FaultHandlers and Compensation handlers


Developing BPEL Process

Contents of a BPEL Package

• • • • Process definition file ( .bpel file ) Related WSDL files Process deployment descriptor ( deploy.xml ) Optional files – Unified endpoint files ( .epr ) – – Service QOS file (services.xml) XSL files


HelloWorld Sample

• • Generate a Synchronous BPEL Process using Developer studio wizard Implement ‘assign’ Logic

Invoking an External Partner

Invoking a Partner Service

• • • • • Generate BPEL process using the synchronous process template Add an invoke activity with two assign activities Create a PartnerLink and PartnerLinkType Use echo service that comes with the BPS as the external service Deploy and execute the process

Invoking a Partner Service

Q & A

Thank You