Oracle BPEL Process Manager Training
Lab Segments
Last Modified:August 2nd, 2004
For more information:http://otn.oracle.com/bpel
2004.07 BPEL PM Training - Slide 2
List of SegmentsTable of Contents
1. Hello World BPEL Process
2. Invoking a Synchronous Web Service
3. Invoking an Asynchronous Web Service
4. Parallel Processing
5. Conditional Branching
6. Fault Handling
7. User Tasks
8. Invoking a BPEL Process From a JSP
9. Events and Timeouts
10. Java Embedding
11. Miscellaneous
Segment #1HelloWorld BPEL Process
2004.07 BPEL PM Training - Slide 4
Problem/Use CaseHelloWorld BPEL Process
“How do I implement, compile, deploy and run my first BPEL Process? I would like that BPEL Process to generate and return a greeting”
2004.07 BPEL PM Training - Slide 5
BPEL ConceptsHelloWorld BPEL Process
BPEL Process – HelloWorld.bpelWSDL
<receive>
Deployment Descriptor (bpel.xml)
<reply>
Set Greeting<assign>
ClientPartnerLink
Input Message<variable>
Output Message<variable>
ClientApplication
BPEL Console
or
Java/JSP
or
SOAP Client
C#
2004.07 BPEL PM Training - Slide 6
BPEL Concepts | BPEL Source CodeHelloWorld BPEL Process
<process> is the top level element<process> is the top level element
<partnerLink>, channel use to interact with client (and services integrated in process)
<partnerLink>, channel use to interact with client (and services integrated in process)
<variable>: reference to an XML message receive or sent to the <partnerLink>s.
<variable>: reference to an XML message receive or sent to the <partnerLink>s.
Process flow: sequence of activities defining the process logic.Process flow: sequence of activities defining the process logic.
Initiate a new instance of the process when a process request is received
Initiate a new instance of the process when a process request is received
Create and assign greeting to output message.Create and assign greeting to output message.
Send synchronous reply to client passing output variable as responseSend synchronous reply to client passing output variable as response
2004.07 BPEL PM Training - Slide 7
BPEL Designer | Overview
New BPEL Project Wizard
Assigning HelloWorld to
output message
Build, Deploy and Test
HelloWorld BPEL Process
2004.07 BPEL PM Training - Slide 8
BPEL Designer | Create BPEL Project WizardHelloWorld BPEL Process
Create New BPEL ProjectCreate New BPEL Project
2004.07 BPEL PM Training - Slide 9
BPEL Designer | Anatomy of a BPEL Project
Eclipse Project FileEclipse Project File
HelloWorld BPEL Process
BPEL deployment descriptorContains metadata regarding the HelloWorld processBPEL deployment descriptorContains metadata regarding the HelloWorld process
Ant build fileCompile the BPEL project into a BPEL suitcase that can be deployed to the BPEL server
Ant build fileCompile the BPEL project into a BPEL suitcase that can be deployed to the BPEL server
BPEL source fileDefinition of this BPEL processBPEL source fileDefinition of this BPEL process
WSDL of interface of this processInterface that a client would use to initiate the HelloWorld BPEL ProcessWSDL of interface of this processInterface that a client would use to initiate the HelloWorld BPEL Process
2004.07 BPEL PM Training - Slide 10
BPEL Designer | Assign HelloWorld to Output MessageHelloWorld BPEL Process
Drag and drop assign activityDrag and drop assign activity
Create Copy RuleCreate Copy Rule
Use XPath Wizard to create concat XPATH expression:“Hello” + input
Use XPath Wizard to create concat XPATH expression:“Hello” + input
2004.07 BPEL PM Training - Slide 11
BPEL Designer | Build and DeployHelloWorld BPEL Process
Click to build and deploy BPEL suitcase:bpel_HelloWorld_v1.0.jarNote 1: the suitcase will be automatically copied to C:\orabpel\domains\default\deploy directoryNote 2: you can also build from the command line using obant.bat
Click to build and deploy BPEL suitcase:bpel_HelloWorld_v1.0.jarNote 1: the suitcase will be automatically copied to C:\orabpel\domains\default\deploy directoryNote 2: you can also build from the command line using obant.bat
Review output of ant build processReview output of ant build process
2004.07 BPEL PM Training - Slide 12
BPEL Console | DashboardHelloWorld BPEL Process
Here it is! The BPEL Process has been deployed to the server. Click on it to bring up the test formHere it is! The BPEL Process has been deployed to the server. Click on it to bring up the test form
http://localhost:9700/BPELConsole
2004.07 BPEL PM Training - Slide 13
BPEL Console | Deploy And TestingHelloWorld BPEL Process
Post XML message to initiate a test instancePost XML message to initiate a test instance
Click on Visual Flow to review audit trailClick on Visual Flow to review audit trail
Click on activity to view detailed infoClick on activity to view detailed info
2004.07 BPEL PM Training - Slide 14
Lab 1: HelloWorldLab Exercise
1. Create a new synchronous BPEL process named MyHelloWorld.
2. Add “Hello World” logic to it to return the string “Hello “ plus the input string submitted to the process.
2004.07 BPEL PM Training - Slide 15
What Did We Learn?
• How to create a BPEL project (for a synchronous BPEL flow)
• How to assign a value to an XML message/variable• How to build and deploy a BPEL process• How to initiate and test a BPEL process
HelloWorld BPEL Process
2004.07 BPEL PM Training - Slide 16
Related Material
• Initiating a BPEL process from Java• Initiating a BPEL process from SOAP• Creating an asynchronous BPEL process• Changing the input and output types associated with a
BPEL process
HelloWorld BPEL Process
Segment #2Invoking a Synchronous Web Service
2004.07 BPEL PM Training - Slide 18
Problem/Use CaseInvoking a Synchronous Web Service
“How do I invoke a synchronous credit rating web service from within a BPEL process?”
Self-Described Interface(WSDL)
Transport(SOAP Over HTTP)
Web ServiceFunctional Building Blockprocess operation returns credit rating
CreditRatingInput
CreditRatingResponse
2004.07 BPEL PM Training - Slide 19
BPEL Concepts | <partnerLink> and <invoke>HelloWorld BPEL Process
BPEL ProcessWSDL
<receive>
Deployment Descriptor (bpel.xml)
<reply>
Call service<invoke>
ClientPartnerLink
Input Message<variable>
Output Message<variable>
ClientApplication
WSDL
CreditRatingPartnerLink
Credit RatingService
prepare crIn<assign>
Read crOut<assign>
d3
d4
d1
d2
crIn <variable>
crOut <variable>
2004.07 BPEL PM Training - Slide 20
BPEL Concepts|Configuring a <partnerLink> Invoking a Synchronous Web Service
Syntax/Example
Tips and TricksCross reference between partner WSDL, .bpel implementation and deployment descriptor. Make sure the namespaces match!
<plnk:partnerLinkType name="CreditRatingService"><plnk:role name="CreditRatingServiceService">
<plnk:portType name="tns:CreditRatingService" /></plnk:role>
</plnk:partnerLinkType>
<partnerLinks><partnerLink name="creditRatingService"
partnerLinkType="crs:CreditRatingService"partnerRole="CreditRatingServiceService"/>
</partnerLinks>
<?xml version="1.0" encoding="UTF-8"?><bpel-process src="LoanFlow.bpel LoanFlow.wsdl"><properties id="creditRatingService">
<property name="wsdl-location">http://localhost:9700/orabpel/default/CreditRatingService?wsdl</property>
</properties></bpel-process>
Extract of the Credit Rating WSDL file
Extract of LoanFlow.bpel
Extract of LoanFlow’s deployment descriptor – bpel.xml
2004.07 BPEL PM Training - Slide 21
BPEL Concept | Source Code Review (I)Invoking a Synchronous Web Service
<partnerLink>Reference to the service we will be calling<partnerLink>Reference to the service we will be calling
<variable> Reference to the XML documents that will be exchanged<variable> Reference to the XML documents that will be exchanged
2004.07 BPEL PM Training - Slide 22
BPEL Concepts | Source Code Review (II)Invoking a Synchronous Web Service
Copy SSN from input of process to document sent to the serviceCopy SSN from input of process to document sent to the service
Copy rating value from service response to the output of the BPEL process
Copy rating value from service response to the output of the BPEL process
Invoke CreditRating serviceInvoke CreditRating service
2004.07 BPEL PM Training - Slide 23
BPEL Designer | OverviewInvoking a Synchronous Web Service
Declare a partnerLink
Define an invoke activity
Define input and output data mapping
2004.07 BPEL PM Training - Slide 24
BPEL Designer | Declaring a <partnerLink> (I)Invoking a Synchronous Web Service
Click to browse UDDIClick to browse UDDI
Click to add partnerLinkClick to add partnerLink
2004.07 BPEL PM Training - Slide 25
BPEL Designer | Defining an <invoke> activityInvoking a Synchronous Web Service
Drag and drop invoke <activity> onto process mapDrag and drop invoke <activity> onto process map
Use wizard to create global variables for messages that will be sent and received from service.
Use wizard to create global variables for messages that will be sent and received from service.
2004.07 BPEL PM Training - Slide 26
BPEL Designer | Input and Output MappingInvoking a Synchronous Web Service
Drag and drop invoke <assign>activity onto process mapDrag and drop invoke <assign>activity onto process map
Create new copy rule to copy input value of BPEL process into SSN field of crIn document Note: crIn is the document we are going to send to the credit service
Create new copy rule to copy input value of BPEL process into SSN field of crIn document Note: crIn is the document we are going to send to the credit service
2004.07 BPEL PM Training - Slide 27
BPEL Console | Deploy And TestingInvoking a Synchronous Web Service
2004.07 BPEL PM Training - Slide 28
Lab 2: Invoking a Synchronous ServiceLab Exercise
1. Create a new asynchronous BPEL project named MyLoanFlow.
2. Change the interface to your BPEL process to accept a LoanApplication document as input and return a LoanOffer.
3. Add the logic to MyLoanFlow to invoke the CreditRatingService in C:\orabpel\samples\utils\CreditRatingService.
4. Make sure that the input to the credit rating service comes fromyour LoanApplication input variable and the credit rating response is placed back in the loan application as well.
Extra Credit #1: Manually change your HelloWorld process to be asynchronous.Extra Credit #2: Invoke the CreditRating service deployed on your neighbor’s BPEL
server.
2004.07 BPEL PM Training - Slide 29
What Did We Learn?
• How to create an asynchronous BPEL process• Changing the input and output types associated with a
BPEL process• How to add a new partnerLink to a BPEL process• How to invoke that partnerLink from within the process
flow• How to create the variables referencing the messages
that will be sent to and received from the BPEL process• How to initialize a variable (input and output mapping)
Invoking a Synchronous Web Service
2004.07 BPEL PM Training - Slide 30
Related Material
• Samples for invoking .Net, Axis, JDeveloper services• Managing faults (see Segment 7)• Adding a UDDI or WSIL source to the BPEL designer• RPC-Style vs. Document-Style Services• Invocation through proxy• Invocation through https using username and password• Endpoint configuration: retry and load balancing• Dynamic endpoints
Invoking a Synchronous Web Service
Segment #3Invoking an Asynchronous Service
2004.07 BPEL PM Training - Slide 32
Problem/Use CaseInvoking an Asynchronous Service
“American Loan exposes a web service that can take anywhere from a couple of minutes to a couple days to process a loan application into a loan offer. How can I leverage that asynchronous loan processor service as part of my BPEL Process?”
American LoanAsynchronous Web Service
[2:05] receive[2:06] process…[2:22] callback
Initiate Port
Callback Port
initiate
onResult callback
2004.07 BPEL PM Training - Slide 33
BPEL ConceptsInvoking an Asynchronous Service
BPEL ProcessWSDL
<receive>
Deployment Descriptor (bpel.xml)
<reply>
Initiate service<invoke>
ClientPartnerLink
input <variable>
output <variable>
ClientApplication
BPEL Console
WSDL
LoanServicePartnerLink
AsyncLoan Processor
Service
prepare loanApp<assign>
Read offer<assign>
d3
d4
d1
d2
loanApp <variable>
loanOffer <variable>
Wait for callback<receive>
Callback Port
Initiate Port
Dehydration PointFor scalability and reliability, in-flight instances are pushed to DB until callback is received
2004.07 BPEL PM Training - Slide 34
BPEL Concepts | WS-Addressing and CorrelationInvoking an Asynchronous Service
BPEL Process – HelloWorld.bpel
Initiate service<invoke>
WSDL
LoanServicePartnerLink
AsyncLoan Processor
Service
d3
d4
crIn <variable>
loanOffer <variable>
Wait for callback<receive>
Callback Port
Initiate Portd3
loanOffer <variable>
d4
WS-Addressing Header:• callback location• correlation id (relatesTo)
WS-Addressing Header:• callback location• correlation id (relatesTo)
WS-Addressing Header:• correlation id (relatesTo)Note 1: The correlation id allows the BPEL server to know which instance of the process is waiting for this callback messages.
Note 2: The alternative approach is to use content-based correlation using <correlationSet>
WS-Addressing Header:• correlation id (relatesTo)Note 1: The correlation id allows the BPEL server to know which instance of the process is waiting for this callback messages.
Note 2: The alternative approach is to use content-based correlation using <correlationSet>
[2:05] receive[2:06] process…[2:22] callback
2004.07 BPEL PM Training - Slide 35
BPEL Concepts | Source Code ReviewInvoking an Asynchronous Service
Initiate async. web serviceInitiate async. web service
Wait for asynchronous callbackWait for asynchronous callback
2004.07 BPEL PM Training - Slide 36
BPEL Designer | OverviewInvoking an Asynchronous Service
Declare a partnerLink
Define an invoke activity and a
receive activity
Define input and output data mapping
2004.07 BPEL PM Training - Slide 37
BPEL Designer | <invoke> and <receive>Invoking an Asynchronous Service
Initiate async. web serviceInitiate async. web service
Wait for asynchronous callbackWait for asynchronous callback
2004.07 BPEL PM Training - Slide 38
BPEL Console | Deploy And TestingInvoking an Asynchronous Service
2004.07 BPEL PM Training - Slide 39
Lab 3: Asynchronous ServicesLab Exercise
1. Add the logic to your flow to invoke the asynchronous UnitedLoanservice.
2004.07 BPEL PM Training - Slide 40
What Did We Learn?
• Asynchrony increases reliability and scalability• How to combine two WSDL port types into an
asynchronous conversation• How to initiate an asynchronous web service (<invoke>)• How to wait for an asynchronous web service to
callback (<receive>)• How WS-Addressing is used to exchange correlation Id
and callback location information
Invoking an Asynchronous Service
2004.07 BPEL PM Training - Slide 41
Related Material
• Using content-based correlation using BPEL’s <correlationSet>s
• Managing time-outs (see segment #11)• Handling un-deterministic responses using <pick>• Dehydration and clustering
Invoking an Asynchronous Service
Segment #4Parallel Processing
2004.07 BPEL PM Training - Slide 43
Problem/Use CaseParallel Processing
“Given that AmericanLoan and UnitedLoan can take up to 5 days to process a loan request, is it possible to invoke those services in parallel?”
American LoanUnited Loan
In Parallel
2004.07 BPEL PM Training - Slide 44
BPEL Concepts | <flow> activityParallel Processing
BPEL Process
Initiate service<invoke>
American LoanWait for callback<receive>
<flow>
Initiate service<invoke>
Wait for callback<receive>
<sequence> <sequence>
United Loan
2004.07 BPEL PM Training - Slide 45
BPEL Concepts | Source Code ReviewParallel Processing
Use <flow> to define parallel branchingUse <flow> to define parallel branching
This is one branchThis is one branch
This is a second branchThis is a second branch
2004.07 BPEL PM Training - Slide 46
BPEL Designer | Defining Two Parallel Execution FlowsParallel Processing
Use <flow> activity to define two or more parallel paths of execution.Use <flow> activity to define two or more parallel paths of execution.
flow is hereflow is here
2004.07 BPEL PM Training - Slide 47
BPEL Console | Deploy And TestingParallel Processing
Both <sequence>s are executed in parallelBoth <sequence>s are executed in parallel
2004.07 BPEL PM Training - Slide 48
Lab 4: Parallel ProcessingLab Exercise
1. Enclose your invocation of the credit rating service in a <scope> activity (just for readability, as your flow grows).
2. Add a <flow> with two branches/<sequences>’s. Move your UnitedLoan invocation to one branch and add the logic to invoke the StarLoan service to the other branch.
2004.07 BPEL PM Training - Slide 49
What Did We Learn?
• How to split the flow of execution into two parallel branches
Parallel Processing
2004.07 BPEL PM Training - Slide 50
Related Material
• flowN and dynamic branching• Non blocking invoke (Synchronous parallelism)
Parallel Processing
Segment #5Conditional Branching
2004.07 BPEL PM Training - Slide 52
Problem/Use CaseConditional Branching
“I have received two loan offers (one from UnitedLoan and one from StarLoan). How do I select the one with the lowest rate?”
2004.07 BPEL PM Training - Slide 53
BPEL Concept | <switch> ActivityConditional Branching
BPEL Process
<switch>
SelectunitedLoan<assign>
<case condition1> <otherwise>
?
SelectstarLoan<assign>
condition1Boolean XPATH Expression
2004.07 BPEL PM Training - Slide 54
BPEL Concepts | Source Code ReviewConditional Branching
Conditional branchingConditional branching
If rate for offer 1 is greater than rate for offer 2If rate for offer 1 is greater than rate for offer 2
Otherwise...Otherwise...
2004.07 BPEL PM Training - Slide 55
BPEL Designer | Define <switch> ActivityConditional Branching
Use <switch> activity to define conditional branchingUse <switch> activity to define conditional branching
Define <case> condition using an XPATH Boolean expressionDefine <case> condition using an XPATH Boolean expression
2004.07 BPEL PM Training - Slide 56
Lab 5: Conditional Branching LogicLab Exercise
1. Add a <switch> activity so that your process returns the better loan offer (the one with the lower APR).
2004.07 BPEL PM Training - Slide 57
What Did We Learn?
• How to add a <switch> activity to the process flow• How to define a case using an XPATH Boolean
expression
Conditional Branching
2004.07 BPEL PM Training - Slide 58
Related Material
• <while> activity• Tutorial #3 on XPATH expressions• Escaping special characters in XPATH expressions• Defining custom XPATH functions
Conditional Branching
Segment #6Fault Handling
2004.07 BPEL PM Training - Slide 60
Problem/Use CaseFault Handling
“The Credit Rating service throws a {http://services.otn.com}NegativeCreditfault under certain conditions. How do I catch and manage a fault from within a BPEL process?”
Credit Rating Service
NegativeCredit Fault!
2004.07 BPEL PM Training - Slide 61
BPEL Concepts | Fault and WSDLFault Handling
WSDL of credit rating service
2004.07 BPEL PM Training - Slide 62
BPEL Concepts | <scope>, <faultHandlers>/<catch>Fault Handling
BPEL Process
<receive>
<reply>
Credit RatingService
d1
d2
Call service<invoke>
prepare crIn<assign>
Read crOut<assign>
<scope>
<catch NegativeCredit>
credit to -1000<assign>
f1
d3
NegativeCredit!
2004.07 BPEL PM Training - Slide 63
BPEL Concepts | Source Code ReviewFault Handling
<scope> is a wrapper element. It allows us to catch a number of exceptions
<scope> is a wrapper element. It allows us to catch a number of exceptions
<catch> NegativeCredit exception thrown by CreditRating service (when SSN starts with 0)
<catch> NegativeCredit exception thrown by CreditRating service (when SSN starts with 0)
Handle exception by setting credit rating to ‘-1000’Handle exception by setting credit rating to ‘-1000’
2004.07 BPEL PM Training - Slide 64
BPEL Designer | Overview
Wrap activity in <scope>
Add <catch> to <scope>
Implement <catch> body
Fault Handling
2004.07 BPEL PM Training - Slide 65
BPEL Designer | Add <catch> to <scope>Fault Handling
Add new <catch> to <scope>Add new <catch> to <scope>
Click to drill into <catch> implementationClick to drill into <catch> implementation
2004.07 BPEL PM Training - Slide 66
BPEL Designer | Implement <catch> bodyFault Handling
Model <catch> process logicModel <catch> process logic
Navigate back to scope elementNavigate back to scope element
2004.07 BPEL PM Training - Slide 67
BPEL Console | Deploy And TestingFault Handling
2004.07 BPEL PM Training - Slide 68
Lab 6: Fault HandlingLab Exercise
1. Add a <faultHandler> to your scope enclosing the credit rating service to handle the NegativeCredit faults which may be thrown by the service.
2. Handle the faults in an automated fashion (here, just set the creditRating value to -1000).
Extra Credit #1: Add a catchAll to catch unhandled faults. Then undeploy your CreditRatingService and see how the system fault can be caught and handled.
Extra Credit #2: Use your neighbor’s CreditRatingService as a failover service and run your flow again to see how the failover capability works.
2004.07 BPEL PM Training - Slide 69
What Did We Learn?
• How to read a WSDL file to determine that a service invocation might generate a fault
• How to wrap an <invoke> activity into a scope to be able to catch and manage a fault
Fault Handling
2004.07 BPEL PM Training - Slide 70
Related Material
• See Tutorials 107.ExceptionSample for how to handle asynchronous error messages using <pick>
• Business exceptions versus system faults• Configuring retries and load balancing for runtime
exceptions• Making BPEL processes resilient using user tasks and
JMS dead letter queues (Tech Note # BPEL-TN007)
Fault Handling
2004.07 BPEL PM Training - Slide 71
Related Material – System Faults
• Oracle BPEL PM defines two kinds of system faults:– RemoteFault (which is re-tryable)– BindingFault (not re-retryable)– Both in namespace
"http://schemas.collaxa.com/bpel/extension”
• See technote on Runtime Faults for more information
Fault Handling
Segment #7User Task
2004.07 BPEL PM Training - Slide 73
Problem/Use CaseUser Task
“How do I integrate a user review step within a BPEL process? I would like that step to be implemented by a custom web application that displays the StockReviewSheet to the user and allows the review task to be updated and completed.”
2004.07 BPEL PM Training - Slide 74
lookupTask(taskId)
listTasksByAssignee( assignee )
BPEL Concepts | TaskManager ServiceUser Task
receive
BPEL Process
invoke
invoke
receive
TaskManager
(Service)
initiateTask( task )
onTaskResult( task )
WSDL Interface
WorklistPage(JSP)
Worklist Java API
DisplayTask(JSP)
CompleteTask(JSP)completeTask(taskId)
Minutes, hours or days
CustomWeb Application
TaskManagerService
2004.07 BPEL PM Training - Slide 75
BPEL Concepts | TaskManager Service InterfaceUser Task
TaskManager
(Service)
initiateTask( task )
onTaskResult( task )
WSDL InterfaceTaskManager.wsdl
updateTask( task )
completeTask( task )
onTaskExpired( task )
BPELBusiness Process
2004.07 BPEL PM Training - Slide 76
BPEL Concepts | Task DocumentUser Task
taskMessage
task element
attachment (anyType)
taskId (string)title (string)creationDate (dateTime) creator(string)modifyDate (dateTime)modifier (string)assignee (string)status (active | completed)expired (boolean)expirationDate (dateTime) duration (duration)priority (int)customKey (string)conclusion (string)
2004.07 BPEL PM Training - Slide 77
listTasksByAssignee( assignee )
lookupTask(taskId)
BPEL Concepts | Worklist Java APIUser Task
TaskManager
(Service)
initiateTask( task )
onTaskResult( task )
WorklistPage(JSP)
Worklist Java API
DisplayTask(JSP)
CompleteTask(JSP)completeTask(taskId)
CustomWeb Application
2004.07 BPEL PM Training - Slide 78
BPEL Concepts | Java XML FacadesUser Task
XML Façade (aka JAXB++): A set of Java classes, generated based on an XML Schema definition, allowing a developer to create and manipulate a DOM tree through a bean-like interface. Note: a Façade is a view; it does not duplicate the underlying DOM tree.
StockReviewSheet XML Façade
setSymbol/getSymbolgetTargetPrice/setTargetPrice….
In the context of the UserTask segment, XML Facades make it easier for developers to manipulate (read/update) the attachment associated with a TaskMessage.
schemac
Defined in *.wsdl or *.xsd file
2004.07 BPEL PM Training - Slide 79
BPEL Concepts | Code ReviewUser Task
The UserTask macro is composed of several BPEL activities:
1) The outer review <scope> wraps all the details
2) The configureTask <assign> activity prepares the task document (assignee, title, priority, expiration date, attachment)
3) The setPayload <assign> creates the taskMessage that will be sent to the TaskService
4) The initiateTask <invoke> sends the taskMessage to the task service and asks for a task to be added to the worklist of the assignee
5) The onTaskResult <receive> waits until the assignee completes the task
6) The readPayload <assign> reads the updated task document and updated the process variable
The UserTask macro is composed of several BPEL activities:
1) The outer review <scope> wraps all the details
2) The configureTask <assign> activity prepares the task document (assignee, title, priority, expiration date, attachment)
3) The setPayload <assign> creates the taskMessage that will be sent to the TaskService
4) The initiateTask <invoke> sends the taskMessage to the task service and asks for a task to be added to the worklist of the assignee
5) The onTaskResult <receive> waits until the assignee completes the task
6) The readPayload <assign> reads the updated task document and updated the process variable
2004.07 BPEL PM Training - Slide 80
BPEL Designer | Overview
Drag User Task palette item
Define Task Name
Configure Task Document(assignee,priority,
attachment)
User Task
Build Web App UI
(list, display, complete)
2004.07 BPEL PM Training - Slide 81
BPEL Designer | Add User Task to Process FlowUser Task
Drag and drop user task element to generate user task macroDrag and drop user task element to generate user task macro
2004.07 BPEL PM Training - Slide 82
BPEL Designer | Prepare Task DocumentUser Task
Edit copy rule to configure each element of the task document used to ask user to review loan offer.
Edit copy rule to configure each element of the task document used to ask user to review loan offer.
2004.07 BPEL PM Training - Slide 83
BPEL Designer | Building a Java UI for Listing Tasks (I)User Task
Import the client packages associated with WorklistImport the client packages associated with Worklist
Use Locator to connect to BPEL Server and get access to worklist service
Use Locator to connect to BPEL Server and get access to worklist service
Retrieve list of tasks assigned to an IDRetrieve list of tasks assigned to an ID
C:\o
rabp
el\s
ampl
es\t
utor
ials
\110
.Use
rTas
ks\T
askS
ampl
eUI\
listT
asks
.jsp
2004.07 BPEL PM Training - Slide 84
BPEL Designer | Building a Java UI for Listing Tasks (II)User Task
Iterate through list of tasks and create table viewIterate through list of tasks and create table view
Retrieve title, id, expiration date and priority associated with the taskRetrieve title, id, expiration date and priority associated with the task
We are only interested in the tasks generated by the TaskSample BPEL process
We are only interested in the tasks generated by the TaskSample BPEL process
Create link to allow user to drill down and view the details associated with a task.Create link to allow user to drill down and view the details associated with a task.
C:\o
rabp
el\s
ampl
es\t
utor
ials
\110
.Use
rTas
ks\T
askS
ampl
eUI\
listT
asks
.jsp
2004.07 BPEL PM Training - Slide 85
BPEL Designer | Building a Java UI for Displaying a TaskUser Task
Look up task based on task idLook up task based on task id
Get a DOM reference to the Stock Review Sheet XML documentGet a DOM reference to the Stock Review Sheet XML document
Use XML Façade bean to extract information from DOM element and present it into an HTML form
Use XML Façade bean to extract information from DOM element and present it into an HTML form
C:\o
rabp
el\s
ampl
es\t
utor
ials
\110
.Use
rTas
ks\T
askS
ampl
eUI\
disp
layT
ask.
jsp
2004.07 BPEL PM Training - Slide 86
BPEL Designer | Building a Java UI for Updating a TaskUser Task
Use XML Façade bean to create a StockReviewSheet based on posted informationUse XML Façade bean to create a StockReviewSheet based on posted information
Attach updated StockReviewSheet to taskAttach updated StockReviewSheet to task
Assign conclusion to taskAssign conclusion to task
Mark task as completedMark task as completedC:\o
rabp
el\s
ampl
es\t
utor
ials
\110
.Use
rTas
ks\T
askS
ampl
eUI\
com
plet
eTas
k.js
p
2004.07 BPEL PM Training - Slide 87
BPEL Console | Deploy And TestingUser Task
Task Service
1
2
3
45
TaskSampleUI.war
listTasks.jsp
displayTask.jsp
completeTask.jsp
2004.07 BPEL PM Training - Slide 88
Lab 7: User TasksLab Exercise
1. Add a manual approval step so that your user will manually approve/confirm the selected loan offer.
2. Use the http://localhost:9700/BPELConsole/tasks.jsp UI to complete the task during testing.
3. Test and review the C:\orabpel\samples\tutorials\110.UserTasks sample to see how to build a custom UI for a user task.
Extra Credit: Modify the TaskSampleUI to provide a custom web interface for your user to complete the loan offer approval step.
2004.07 BPEL PM Training - Slide 89
What Did We Learn?
• How to include a user interaction in a BPEL process using the TaskManager service
• How to use the Java API of the TaskService to build a JSP that lists all the tasks assigned to a user
• How to use the Java API of the TaskService to build a JSP that displays the contents of a specific task
• How to use the Java API of the TaskService to build a JSP that updates the content of a task and marks it as completed
User Task
2004.07 BPEL PM Training - Slide 90
Related Material
• Building a C# app for listing, viewing and completing tasks
• Using LDAP for assignment/escalation• Email notification• The TaskManager Java API and JTA (see BPEL-TN006
regarding crash testing BPEL PM)
User Task
Segment #8Invoking a BPEL Process From a JSP
2004.07 BPEL PM Training - Slide 92
Problem/Use CaseInvoking a BPEL Process From a JSP
“I have implemented and deployed an asynchronous HelloWorld BPEL process. How do I initiate it from a Java/JSP application?”
BPEL
ClientApplication
JSP or Java
initiate
A BPEL process
2004.07 BPEL PM Training - Slide 93
BPEL Concepts | Java Business DelegateInvoking a BPEL Process From a JSP
BPEL Process
<receive>
<reply>
ClientPartnerLink
d1
d2
SOAP/WSDL
Java Business Delegate(Delivery Service)
Each deployed BPEL process can be invoked as a Web Service through its WSDL/SOAP interface or as a Java component through its Java Business Delegate Interface (aka Delivery Service)
2004.07 BPEL PM Training - Slide 94
BPEL Designer | Invoking a BPEL Process from a JSPInvoking a BPEL Process From a JSP
Include client API packagesInclude client API packages
Create XML representation of the payload of the message that will be posted to the BPEL Process Note: XML Façade could have been used here if the document were more complex.
Create XML representation of the payload of the message that will be posted to the BPEL Process Note: XML Façade could have been used here if the document were more complex.
Use Locator to obtain a reference to the delivery service of the BPEL server
Use Locator to obtain a reference to the delivery service of the BPEL server
Create normalized message and attach payloadCreate normalized message and attach payload
Post message to the HelloWorld BPEL Process.Note: message will be queued by delivery service and processed by BPEL PM based on priority and load.
Post message to the HelloWorld BPEL Process.Note: message will be queued by delivery service and processed by BPEL PM based on priority and load.
C:\o
rabp
el\s
ampl
es\t
utor
ials
\102
.Inv
okin
gPro
cess
es\j
sp\in
voke
Hel
loW
orld
.jsp
2004.07 BPEL PM Training - Slide 95
Lab 8: Invoking BPEL Processes through SOAP and JavaLab Exercise
1. Modify C:\orabpel\samples\tutorials\102.InvokingProcesses\jsp\invokeHelloWorld.jsp to invoke your MyLoanFlow BPEL process through the Java API.
Extra Credit: Modify the RMI client sample to initiate your MyLoanFlow process via RMI.
2004.07 BPEL PM Training - Slide 96
What Did We Learn?
• Once deployed, a BPEL process is exposed through both a WSDL/SOAP interface and a Java business delegate interface
• The Java business delegate interface allows Java/JSP applications to initiate new instances of a BPEL process
• The Java business delegate can be used locally or remotely using RMI
• The Java business delegate is JTA aware, allowing the initiation of a process to be part of a broader transaction
Invoking a BPEL Process From a JSP
2004.07 BPEL PM Training - Slide 97
Related Material
• com.oracle.bpel.client.* Java docs• Invoking a BPEL process from a .NET client (VB or C#)• Configuring the WS-Addressing header• Instance processing and priority• Queuing through the delivery service
Invoking a BPEL Process From a JSP
Segment #9Events and Time-outs
2004.07 BPEL PM Training - Slide 99
Problem/Use CaseEvents and Time-outs
“StarLoan is supposed to call us back with a LoanOffer within an hour. What happens if it doesn’t? How can I handle this time-out within my BPEL process?”
2004.07 BPEL PM Training - Slide 100
BPEL Concepts | <pick> and <onAlarm>Events and Time-outs
BPEL Process
American Loan
<pick>
Wait for callback<onMessage>
Initiate service<invoke>
Time out in 1M<onAlarm>
Logic post callback Logic post timeout Note:
<pick> will trigger the onMessage or the onAlarm (exclusive-or).
If you want to handle the timeout but keep on waiting for callback, you should consider <scope>…<onAlarm> instead.
2004.07 BPEL PM Training - Slide 101
BPEL Concepts | Source Code ReviewEvents and Time-outs
Define a <pick> with two branches:• one to receive a callback from the
loan processor (<onMessage>), • the other to manage a 1-minute
timeout (onAlarm)
Define a <pick> with two branches:• one to receive a callback from the
loan processor (<onMessage>), • the other to manage a 1-minute
timeout (onAlarm)
2004.07 BPEL PM Training - Slide 102
BPEL Designer | Overview
Replace <receive> with <pick> + <onMessage>
Define and configure <onAlarm>
Events and Time-outs
2004.07 BPEL PM Training - Slide 103
BPEL Designer | Configuring a <pick>Events and Time-outs
Use <pick> activity to manage timeoutUse <pick> activity to manage timeout
Set a 1 minute timeout (PT1M) using <onAlarm>Format for XML duration is:P1Y2M3DT5H10M1S1 year, 2 months, 3 days, 5 hours, 10 minutes, 1 second
Set a 1 minute timeout (PT1M) using <onAlarm>Format for XML duration is:P1Y2M3DT5H10M1S1 year, 2 months, 3 days, 5 hours, 10 minutes, 1 second
2004.07 BPEL PM Training - Slide 104
BPEL Console | Deploy And TestingEvents and Time-outs
Timeout: Alarm gets triggered before callback.Timeout: Alarm gets triggered before callback.
2004.07 BPEL PM Training - Slide 105
Lab 9: Events and Time-outsLab Exercise
1. Use <pick> / <onMessage> / <onAlarm> so that your process waits a maximum of 1 minute for the StarLoan response.
Extra Credit: Add an alarm to your top level BPEL <process> activity, which terminates execution of the process after 5 minutes.
2004.07 BPEL PM Training - Slide 106
What Did We Learn?
• How to replace a <receive> by a <pick> + <onMessage> + <onAlarm> to be able to specify and handle a timeout
• How to set the duration of a timeout
Events and Time-outs
2004.07 BPEL PM Training - Slide 107
Related Material
• Managing un-structured events using:<scope> + <onMessage>
Events and Time-outs
Segment #10Java Embedding
2004.07 BPEL PM Training - Slide 109
Problem/Use CaseJava Embedding
“I have a Customer Entity Bean that allows me to retrieve a SSN based on an email id. How can I invoke that bean from within my BPEL process?”
BPEL
call
A BPEL process CustomerEntity Bean
2004.07 BPEL PM Training - Slide 110
BPEL Concepts | BPEL/Java IntegrationJava Embedding
There are 3 solutions to this problem:
• Wrapping the Java component into a full blown web service using JDeveloper or Axis
• Using the WSIF Java Binding
• Using the Java BPEL exec extension (<bpelx:exec>)
2004.07 BPEL PM Training - Slide 111
BPEL Concepts | <bpelx:exec>Java Embedding
<bpelx:exec>
1. BPEL Extension which allows developers to embed a snippet of Java code within a BPEL process
2. When the <bpelx:exec> is reached, the server executes the snippet of Java code (within its JTA transaction context)
3. A set of built-in methods allow developers to read and update scope variables, instance metadata and audit trail
4. XML Façade can be used to simplify DOM manipulation
5. Java exceptions are converted into BPEL faults and bubbled into BPEL process
6. The snippet can propagate its JTA transaction to session and entity beans that it calls
2004.07 BPEL PM Training - Slide 112
BPEL Concepts | <bpelx:exec> Source CodeJava Embedding
<bpelx:exec allows you to embed a Java snippet within a BPEL process<bpelx:exec allows you to embed a Java snippet within a BPEL process
Use getVariableData built-in method to access scope variables. Use XML Façade to simplify DOM manipulation.
Use getVariableData built-in method to access scope variables. Use XML Façade to simplify DOM manipulation.
Look up entity bean.Look up entity bean.
Log SSN to audit trail of this instanceLog SSN to audit trail of this instance
Catch and log any potential exceptionsCatch and log any potential exceptions
2004.07 BPEL PM Training - Slide 113
BPEL Concepts | <bpelx:exec> Built-in MethodsJava Embedding
Object lookup( String name )
Locator getLocator( )
long getInstanceId( )
String setTitle( String title ) / String getTitle()
String setStatus( String status ) / String getStatus()
void setIndex( int i, String value ) / String getIndex( int i )
void setPriority( int priority ) / int getPriority()
void setCreator( String creator ) / String getCreator()
void setCustomKey( String customKey ) / String getCustomKey()
void setMetadata( String metadata ) / String getMetadata ()
String getPreference( String key )
void addAuditTrailEntry(String message, Object detail)
void addAuditTrailEntry(Throwable t)
File getContentFile( String rPath )
Object getVariableData(String name) throws BPELFault
Object getVariableData(String name, String partOrQuery) throws BPELFault
Object getVariableData(String name, String part, String query)
void setVariableData(String name, Object value)
void setVariableData(String name, String part, Object value)
void setVariableData(String name, String part, String query, Object value)
// JNDI access
// BPEL PM Locator
// Unique id associated with each instance
// Title of this instance
// Status of this instance
// 6 indexes can be used for search
// Priority
// Who initiated this instance?
// Second primary key
// Metadata for generating lists
// Access preference defined in bpel.xml
// Add entry to audit trail
// Add exception to audit trail
// Access file stored in suitcase
// Access and update variables stored in scope
2004.07 BPEL PM Training - Slide 114
BPEL Designer | Adding a Java <exec> ActivityJava Embedding
Drag and drop from palette.Use BPEL source view to edit.Drag and drop from palette.Use BPEL source view to edit.
2004.07 BPEL PM Training - Slide 115
BPEL Console | Deploy And TestJava Embedding
2004.07 BPEL PM Training - Slide 116
Lab 10: Java EmbeddingLab Exercise
1. Add a Java <bpelx:exec> activity to your process to use Java to do some basic validation on the email address in the loan application document.
Extra Credit: Embed your functionality within a Java class and compile that Java class and include it in a BPEL-INF\classes directory in your BPEL project.
2004.07 BPEL PM Training - Slide 117
What Did We Learn?
• There are 3 ways to integrate an existing Java component into a BPEL process: 1) wrapping that component in a SOAP service, 2) using a binding framework such as WSIF or 3) inline a code snippet using <bpelx:exec>
• The <bpelx:exec> snippet is executed within the transaction context of the BPEL server. You can propagate that transaction to your own session and entity beans
• A set of built-in methods allow the <bpelx:exec> snippet to read and update variables, change instance metadata and throw faults
• XML Façade can be used within a snippet to simplify DOM manipulation
Java Embedding
2004.07 BPEL PM Training - Slide 118
Related Material
• WSIF Java Binding• Transaction propagation and crash testing• Using the BPEL-INF/lib and classes to package your Java
library dependencies into the “BPEL suitcase”deployment unit
Java Embedding
Segment #11Miscellaneous
2004.07 BPEL PM Training - Slide 120
Lab 11: Extra Exercises
• A more complex example: Sabre TravelFlow• Interacting with heterogeneous Web services• TCP Tunneling SOAP messages / WS-Addressing• Using Oracle 9i as dehydration store• .NET interoperability• SAP integration
Miscellaneous
2004.07 BPEL PM Training - Slide 121
A More Complex Example: Sabre TravelFlow
• <to be created>
Extra Exercises
2004.07 BPEL PM Training - Slide 122
Interacting with Heterogeneous Web ServicesExtra Exercises
1. Invoke one of the services deployed to www.xmethods.org.
Note: If you are behind a proxy server, this will require following the instructions in tech note http://otn.oracle.com/products/ias/bpel/htdocs/orabpel_technotes.tn002.html to configure how Web service call to go through your proxy server.
In the training lab, edit C:\orabpel\bin\obsetenv.bat to have (all on one line):
set OB_JAVA_PROPERTIES="-Djavax.wsdl.factory.WSDLFactory=oracle.j2ee.ws.wsdl.factory.WSDLFactoryImpl" "-Dhttp.proxySet=true" "-Dhttp.proxyHost=138.3.236.164" "-Dhttp.proxyPort=80" "-Dhttp.nonProxyHosts=localhost|<hostname>"
2004.07 BPEL PM Training - Slide 123
TCP Tunneling SOAP Messages
• <to be created>
Extra Exercises
2004.07 BPEL PM Training - Slide 124
Using Oracle 9i as a Dehydration Store
• <to be created>
Extra Exercises
2004.07 BPEL PM Training - Slide 125
.NET Interoperability
• <to be created>
Extra Exercises
2004.07 BPEL PM Training - Slide 126
SAP Integration
• <to be created>
Extra Exercises
2004.07 BPEL PM Training - Slide 127
Backup Slides
Segment #1Segment Name
2004.07 BPEL PM Training - Slide 129
Problem/Use CaseSegment Name
One sentence description of use case
2004.07 BPEL PM Training - Slide 130
BPEL Concepts
2004.07 BPEL PM Training - Slide 131
BPEL Concepts | Source Code ReviewReference to the service we will be callingReference to the service we will be calling
2004.07 BPEL PM Training - Slide 132
BPEL Designer | Overview
Step 1 Step 2 Step 3
2004.07 BPEL PM Training - Slide 133
BPEL Designer | Step1
Click to add partnerLinkClick to add partnerLink
2004.07 BPEL PM Training - Slide 134
BPEL Console | Deploy And TestingFill SSN and click on post XML messageFill SSN and click on post XML message
2004.07 BPEL PM Training - Slide 135
What Did We Learn?
2004.07 BPEL PM Training - Slide 136
Related Material
Top Related