Title: Invoking BPEL Business Process from ADF using Web Service Proxy
Transcript of Title: Invoking BPEL Business Process from ADF using Web Service Proxy
Title: Invoking BPEL Business Process from ADF using Web Service Proxy
Version 1.0, Date July 01, 2008
Objective
The Objective of this Exercise is to create one of the simplest BPEL Process using
JDeveloper and Deploy it on Oracle 10g SOA Suite.
Generate Web Service Proxy Client to access the Deployed Business Process
Create a Simple JSF-ADF Page to Access this web service and display the results in
JSF after invocation.
Respect J2EE Model View Controller Architecture to Build the Application
Use Case: The BPEL Process would receive input as 2 integers x and y though an
ADF JSF Page, the BPEL Process would then sum up the two integers and return back
the result to the ADF Page.
A web service proxy is generated to help in connectivity between ADF Page and
WSDL generated by the BPEL Process
Topics
• Architecture
• Creating a Business Process
• Build Deploy and Test Business Process
• Create Web Application Generate Proxy ADF / JSF Web Application
• Create JSF Page to invoke BPEL Process through Generated Proxy
• Display Results on Page
• Software Needed
• Tips and Tricks
• Summary
Architecture
The Architecture shows end user entering input data into JSF Page at View Controller
Layer, The JSF Managed Bean would invoke the Web Service Proxy at the Model
Layer, Request Action would pass the input variables to the BPEL Process which is
Accessed through WSDL URL, The Response would bring back the data which will be
used to display on the web page.
BPEL Process is created using Jdeveloper and Deployed on SOA Suite.
JSF Pages can be deployed on OC4J or one can even use Jdeveloper’ s inbuilt Web
center Server.
Create a Business Process using JDeveloper
The scope of this document is more into how to invoke the business process pass
data into it and receive the response back, rather than the development of BPEL
Process itself.
Lets create a simplest Business Process where we will ADD two numbers and display
its Sum as an end Result of Business Process.
Start the Jdev. Right click on Applications, Select New Application give name as
“SimpleProcess” Select “No Template” as Application Template. Click OK
Right click on the “SimpleProcess” and create a new Project “BPEL Process Project”
give the name as “SummationProject” select “Synch BPEL Process” as Template, click
Finish.
Lets update the XSD File to match our input and out put requirements, so edit
SummationProcess.xsd (Auto generated file) and define Request variables as X and Y
both of type integer and Response variable as sum which is also of type integer.
Either one could use Jdev user interface to drag and drop elements or edit source
directly which ever you feel is easy you can use it.
Refer the figure shown below.
Double Click and Open SummationProcess.bpel file which is a canvas to design our
BPEL Process.
Drag and Drop an “Assign” activity from “Component Palette” on extreme right
between “receiveinput” and “replyoutput” activities
Name this Assign Activity as “CalcSum”
Click on Copy Operation Tab, create a Copy Operation to assign output variable sum
equals to input variable x + variable y, on the input side one needs to select
Expression as a Type to do this.
Expression will be as shown below
The final Business Process looks as shown in the above figure. Well … probably this is
the most simplest business process other than “HelloWorld” Process one could think
of.
Build, Deploy and Test Business Process
Establish the connection with the SOA Suite as a pre requisite , through Connection
Navigator.
Right Click on the Process and Deploy it to SOA Server Connection.
Once deployment is Successfully Completed, login to BPEL Console at this URL
http://localhost:8888/BPELConsole/
(its Assumed that SOA Suite is installed on port 8888)
Initiate the Summation BPEL Process, enter some 2 integers and click on Post XML
Message Button
If the BPEL Process is fine the sum of 2 numbers will be displayed, this was simplest
process with no validation or any complexity involved
Copy the End Point and WSDL URL’s into Notepad from WSDL Tab, which would be
used later.
Create an ADF Project, Generate Web Service Proxy
Create Web Application – Generate Web Service Proxy
Oracle’s JDeveloper is much advanced that it saves one from actually writing client
side Proxy Codes to access Business Process, lets see how this can be done.
Create a New Application by name “SimpleADFPage”, select Web Application JSF ADF
BC Template, and click OK Button. Model and View Controller are Auto generated.
Model is where we will write our Business Logic to access BPEL Process.
Right Click on Model select “All Technologies” expand “Business Tier” select “Web
Services” and select “Web Service Proxy” click OK,
Give the WSDL URL copied on to clipboard which points to our Business Process to be
executed. Check on Copy WSDL into Project
Click Next, let the Package Names be default given
Finally the Proxy Code is Auto Generated Successfully
If one clicks on the Proxy he/she can see all the generated files of which major files
are Proxy Client, Request and Response Java Files.
Create ADF/JSF Page to invoke the Process
Now lets build the view layer, for this right click on View Controller, New Web Tier,
JSF, JSF JSP is selected from the Navigation Menu. As shown in the below fig.
lets give the filename as welcome.jspx and of type *.jspx, click Next
Automatically generate Managed Bean radio button is selected and click finish,
welcome.java is the backing bean which would be very important.
lets drag and drop this welcome.jspx file into faces config.xml and set navigation to
same page as shown in the diagram below, what it means is the page is submitted to
same page after hitting submit button.
We want our java jar files created in the Model to be available at View layer, for this
right click on view go to project properties, select dependencies and check on
Model.jpr as shown in the figure
Save All. Open welcome.jspx and drag and drop UI components like Panel Page,
inputText, Command Button as shown in the figure.
Sum Commands Buttons Action invokes “invokeProcess()” method in welcome.java
Here is the code snipped for “invokeProcess()” method, note that “xVal”, “yVal” are
input text box variable names, “resultVal” is output textbox variable name, these
must be declared in Id column of “Property Inspector”
Use the below picture as a guide to define UI related variables.
Display Results on JSF Page
Welcome.jspx can be run by right clicking on the file and selecting run option
One can test this page by entering various integer values.
Softwares which would be needed
• JDeveloper 10.1.3.3
• SOA Suite 10.1.3.3
These are available at www.oracle.com
Tips and Tricks
• Use Process Scope to bind variables as shown below
AdfFacesContext.getCurrentInstance().getProcessScope().put("xVal",
getXval().getValue());
• Once the page is submitted these variables can be read as
#{processScope.xVal} which is defined in the value Property of UI Element
like Input Text
• Use Faces Config Designer to define Navigation Rules
• When Generating Proxy its better to use hostnames in the wsdl url than using
IP address as IP may change dynamically
Summary
• Its very easy to design Business Process and Deploy on SOA Suite using
Oracle JDeveloper
• No need to write Java coding to invoke BPEL Process by Proxy, JDeveloper
allows easy Client Proxy Creation
• JDeveloper binds to MVC Architecture, where JSF forms the view layer
components and Model will have logic to access business process
• MVC components are deployed on OC4J Container
• BPEL Process is Deployed and Tested as standalone Application on SOA Suite
Author
James Smith s Java Oracle Blogs