52
Kasun Indrasiri Associate Technical PMC, Apache Synapse Member, Integration WSO2 Inc. May 2013 Introduction to WS-BPEL and WSO2 BPS

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

  • Upload
    cady

  • View
    30

  • Download
    1

Embed Size (px)

DESCRIPTION

Introduction to WS-BPEL and WSO2 BPS. Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2 Inc. May 2013. Agenda. What is a Business Process / WS-BPEL WSO2 Business Process Server Introduction to BPEL - PowerPoint PPT Presentation

Citation preview

Page 1: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Kasun IndrasiriAssociate Technical LeadPMC, Apache SynapseMember, Integration MCWSO2 Inc.May 2013

Introduction to WS-BPEL and WSO2 BPS

Page 2: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Agenda

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

Page 3: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Business Process

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

business goal

Page 4: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Example process

Page 5: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Orchestration vs. Choreography

• Orchestration– Business process with central

coordinator– WS-BPEL

• Choreography– Business collaboration

Page 6: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

WS-BPEL

• 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

Page 7: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

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

Page 8: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

WSO2 Business Process Server

• Executes business processes written using WS-BPEL standard• Powered by Apache ODE ( ode.apache.org )• WS-Human Tasks and BPEL4People• Provides a Management Console to

– View and Manage Processes / Human Tasks– View and Manage Instances / Tasks – Configure QOS …

Page 9: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Introduction to WS-BPEL

Page 10: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Want to implement a BPEL Process ?

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

Page 11: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Structure of a WSDL

• <types> • <message/>+• <portType><operation>+</portType>• <binding/>+• <service><port/></service>

Page 12: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

BPEL Document Structure

<process><partnerLinks><partnerLinks><variables></variables><messageExchanges></messageExchanges><correlationSets></correlationSets><faultHandlers></faultHandlers><compensationHandlers></compensationHandlers><eventHandlers></eventHandlers>(activities)*</process>

Page 13: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

BPEL Process

<process name="NCName" targetNamespace="anyURI"queryLanguage="anyURI"?expressionLanguage="anyURI"?suppressJoinFailure="yes|no"?exitOnStandardFault="yes|no"?xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/

executable"></process>

Page 14: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

PartnerLinkType

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

<plnk:partnerLinkType name="BuyerSellerLink"><plnk:role name="Buyer" portType="buy:BuyerPortType" /><plnk:role name="Seller" portType="sell:SellerPortType" />

</plnk:partnerLinkType>

Page 15: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

PartnerLinkType

SellerBuyer

Process Partner Service

Invoke Seller

Send response to Buyer’s Callback

SellerBuyer

Process Partner Service

Invoke Seller

Async Sync

Page 16: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

PartnerLinks

• 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

Page 17: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Partner Links

Page 18: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Partner Link

• Partner Link Associates with a partner link type<partnerLinks>

<partnerLink name=“BuyerSellerPL” partnerLinkType=“BuyerSellerLink”myRole=“Buyer”partnerRole=“Seller”/>

</partnerLinks>• Defines which role should be played by the process itself and the

partner service

Page 19: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Variables

• 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

Page 20: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Variables

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

Page 21: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Activities

• 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

Page 22: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Basic Activities

• Receive• Reply• Invoke• Assign• Empty• Compensate• Catch

• Throw• Rethrow• Exit

Page 23: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Receive

• 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

Page 24: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Reply

• 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

Page 25: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Invoke

• 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

Page 26: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Assign

• Used to manipulate variables

Page 27: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

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.

Page 28: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Expected Content

• echoRequest= <p:echoString xmlns:p="http://echo.services.core.carbon.wso2.org">

<in>HelloWorld</in> </p:echoString>• First we should initialize the variable ‘echoRequest’ before copying

the string value “HelloWorld” to it. • $echoRequest/p:echoString/in

Page 29: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Structured Activities

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

Page 30: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Sequence

• 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<sequence standard-attributes>

standard-elementsactivity+

</sequence>• Contained activities are executed in the order they are defined• Completes when the last activity has completed

Page 31: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Sequence

Page 32: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Flow

• 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

Page 33: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Flow

Page 34: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

If

• 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

Page 35: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

If

Page 36: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Looping

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

Page 37: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

ForEach

Page 38: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

While

Page 39: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

RepeatUntil

Page 40: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Pick

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

Page 41: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Pick

• 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

Page 42: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Scope

• 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

Page 43: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Scope

Page 44: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Developing BPEL Process

Page 45: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

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

Page 46: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Deploy.xml

Page 47: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

HelloWorld Sample

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

Page 48: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Invoking an External Partner

Page 49: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

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

Page 50: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Invoking a Partner Service

Page 51: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Q & A

Page 52: Kasun Indrasiri Associate Technical Lead PMC, Apache Synapse Member, Integration MC WSO2  Inc

Thank You