Saturday, July 21, 2007

Invoking BPEL Process from Oracle ADF Application

In today post I have decided to describe and show how application developed using Oracle ADF can fit into SOA (Service-Oriented-Architecture). SOA is important technology, because it allows developers to find common language with business analysts and as result to develop more useful systems. Simply speaking, SOA allows to participate in system development both parties - IT and non IT. IT folks develop technical things and non IT people are allowed to manage system logic. My goal is to show, how it looks in reality, and how it works with Oracle JDeveloper and Oracle SOA Suite. Sample applications are developed using Oracle JDeveloper 10.1.3.3 and BPEL process is tested on Oracle BPEL Process Manager 10.1.3.1.0. For those who will want to look further, I recommend to browse through Guides and Tutorials available on Oracle BPEL Process Manager 10.1.3.1.0 Information page.

Web application - SalaryBonusApplication.zip and synchronous BPEL process - SalaryBonusProcess.zip are provided as sample applications. Web application Model layer is implemented using Oracle ADF Business Components and is based on standard HR schema, in View layer ADF Faces components are used. Synchronous BPEL process access HR schema using Oracle TopLink.

Developed logic - in Web application users can search for particular employee and select him/her for salary update process. Salary update is based on current salary and applied bonus value. Salary update business logic is implemented in BPEL process. So, it's where we can see a power of SOA - salary update business logic can be changed at any time by non IT people, they will just need to modify defined process.

I will start from process part description. Implemented BPEL process diagram:


In first step, process receives input. In second step, conditional logic is applied and process output is calculated. When process output is known, data is transformed to be compatible with EMPLOYEES table structure from HR schema. After transformation step, employees data update in database is invoked and process is finished.

As it was described, salary update process is based on two parameters - current salary and applied bonus, however employee ID is also needed. Process parameters are described in XSD document:


Process logic is implemented in switch activity. Switch activity rule is based on bonus variable value:


When process output is calculated, data should be transformed in order to be stored in EMPLOYEES table. Transformation can be defined using Oracle JDeveloper wizard tool:


And finally, transformed data is used in database update through Invoke activity:


Yes, database table will be updated from BPEL process. And there is no magic, simply Oracle TopLink object-relational mapping functionality is used. Complete project structure view in Oracle JDeveloper navigator:


Process part description is completed, now we will move to Web application part. Web application contains two forms, first is Search Employees form:


Second form - Edit Employee Salary, can be opened for selected row:


Update Salary button here invokes BPEL process. Salary calculation is done outside of Web application, through Web Service submited values are passed to process where are modified and stored to database. In Web application refresh action is executed and updated values are shown:


You can notice, that salary value is increased by 100, this logic is defined in BPEL:


You may wonder, how BPEL process can be included into Web application developed using Oracle ADF. But it is simple, Oracle JDeveloper provides complete solution - you just need to provide WSDL URL and Data Control for available operations will be generated and displayed in Data Control pallette:


BPEL process is accessed through Web Service specified in DataControls.dcx file:


Action related to BPEL process is defined in page definition file in standard way:


Executed BPEL process instance can be explored from Oracle Enterprise Manager 10g BPEL Control window - executed process steps are represented in visual flow and values available in each step are provided:


When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.

28 comments:

Anonymous said...

"You may wonder, how BPEL process can be included into Web application developed using Oracle ADF. But it is simple, Oracle JDeveloper provides complete solution - you just need to provide WSDL URL and Data Control for available operations will be generated and displayed in Data Control pallette..."

Can you explain in detail.

Thank you in advance!

Andrej Baranovskij said...

Hi,

For sure, I can explain this step in more detail.

1. In Oracle Enterprise Manager 10g BPEL Control, through Dashboard, open your BPEL process and choose WSDL tab. In this tab is provided process WSDL location - copy it

2. In JDeveloper, open New Gallery dialog for your project

3. In New Gallery dialog choose Business Tier -> Web Services -> Web Service Data Control

4. Wizard will be opened. Provide WSDL location URL, define Name, choose Service

5. Other steps are straightforward. In steps - 3 and 4, you can leave empty values as it is by default

When described steps will be completed, Data Control will be generated.

Regards,
Andrejus

Andrej Baranovskij said...

Frank Nimphius have posted today excellent how-to document: Using Web Services with Complex Return Types in ADF

You may find it useful for Web Services invocation from ADF application.

Regards,
Andrejus

Anonymous said...

Hi,
This blog entry is very helpful...but I do have a question.
Once I hit the Update Salary button, it just hangs there. When I go to check the BPEL Control for the instance, there is none. However, the odd part is if I check the database, the data has been updated with the new salary value as if the BPEL process ran correctly.

Have you ever encountered this before?

Also, I noticed that there is code in the UpdateEmployeeSalary.java backing bean that calls the Process. Did you write this, or was it automatically generated with ADF?

Thank you for your help!!


MRC

Andrej Baranovskij said...

Hi,

No, in my environment I haven't encountered this issue. Update process works fine. It is interesting, it hangs when you hit Update button for the first time? If it hangs only for the second time, looks like locking issue. However, I have tested it in my environment again - it works.

Part of that method was generated, it was:

BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("process");
...
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}

Other code was written by me. ADF generates process invocation code, I have just provided values for parameters.

Regards,
Andrejus

Lavanya Siliveri said...

Hi,

I am trying to invoke a synchronous BPEL process from a jspx page. I have configured my BPEL process as web service data control object and
dropped it on my jspx as a button. But after dropping it as a button i observe that it is expecting three parameters. which are cusotmername,customer number and orders-object which is a complex type element in my xsd.

i have a heirarchy of data. I have customerType which has orderType , which further has lineType which are complex types.

the

Can you help me , how do i provide data to this process i.e in the parameter fields., so that it is in accordance with my .xsd of the BPEL process.

-thanks,
lavanya.

Andrej Baranovskij said...

Hi Lavanya,

You can create Action Method for that dropped button in Backing bean. And set values for parameters from that method.

In my sample such method is updateSalaryButton_action() available in updateEmployeeSalary.jspx page backing bean.

So, just double click on your button, provide a name for the method and process invocation code will be generated in backing bean. You will just need to add some code, that will provide values for parameters. Take a look into updateSalaryButton_action().

Regards,
Andrejus

Lavanya Siliveri said...

Hi Andrejus,

thank you very much for a wonderful blog and the reply.

-thanks,
lavanya

Anonymous said...

I want to default an attribute during the load of the screen rather than clicking the commit button on the screen. i.e as and when the service request screen is launched the BPEL process should be invoked and the attribute should be defaulted.How can i achieve this? Any pointers on this will be appreciated?

Andrej Baranovskij said...

Hi,

Probably you may use OnPageLoad method in backing bean. You may find additional info in Duncan Mills blog post - ADF - Executing Code on Page Load.

Regards,
Andrejus

Anonymous said...

Thanks for the reply Andrejus. But i want to invoke the BPEL from Entity Object level. I donot want to use Business Events since they are triggered only on successful commit where as my requirement is to default at the page load.

Andrej Baranovskij said...

Hi,

OnPageLoad method is executed on page load automatically, seems it is what you want. Why it is not suitable for you?

BPEL process is invoked through Web Service. So, you can invoke it from any place in your code, in fact.

Regards,
Andrejus

Dietrich Schroff said...

Hi,

very nice article!
This is should be very useful for every SOA-developer..

Anonymous said...

Hi,
Very good blog.

I have a question (although it might not be related to the subject of this article): I need to include an Oracle 9i legacy package which produces plain HTML page into JDeveloper ADF application. Can you please recommend a solution or point to a related article? Any suggestions are greatly appreciated.

Thank you in advance.

Andrej Baranovskij said...

Hi,

If that package is a JAR file, you can include it into project as a library (right-click your project in JDeveloper, select Properties. In opened window choose Libraries). There is no problem to have HTML page in ADF application, you can open it as any Web resource.

Regards,
Andrejus

Anonymous said...

Thank you for the response.
No, the package is not in JAR file - this is plain PL/SQL package in the database. It is a "monolith" package that does everything: it gets data, updates rows or inserts new rows in tables, and it produces complete HTML page using HTP.P's.

Anonymous said...

This is a beginner's request: could you explain what kind of setups I need to do before running your sample applications? Like where can I download and install the HR schema on my PC (just for the purpose of getting samples to run)?

Andrej Baranovskij said...

Hi,

HR schema is available in Oracle Database 10g Express Edition. This database is free for commercial use also. When you will install database, you will need to unlock HR schema, because it is locked by default.

Most of the sample are developed with JDeveloper 10.1.3.2, but it should not be a problem to run them in any 10.1.3.x

Regards,
Andrejus

Lavanya Siliveri said...

Hello,

JDEV Build : JDEVADF_MAIN.DROP3_GENERIC_070612.1815.4560
SOA : Drop 3 SOA Runtime environment


We are attempting to invoke a synchronous BPEL process from an ADF page, and trying to track the value of few elements in the input payload at various activities of the BPEL process.

In order to achieve the same we have placed sensors on some activities and associated the variables.

The sensor action posts the sensor data to the olite Database. We see that the values of the different sensors are written accordingly in the views BPEL_XXX_SENSOR_VALUES in the BPEL database.

We would like to retrieve the data from these views accordingly and place them in my database tables using the DBAdapter and then refresh my ADF page in certain intervals to show the updated data.

The question is ...... Is there a better way to track the status of the BPEL process even before the process execution is completed ?
Will invoking a DBadapter be a costly affair pertaining to performance?

Anonymous said...

Hi,

Could you let me know the steps for wiring BPEL with ORM application , which is interacting with database.

I can not download your samples in my office system, since it is restricted.

It would be helpful if you provide any other links/articles regarding that.

Andrej Baranovskij said...

Hi,

You can use Oracle® BPEL Process Manager Order Booking Tutorial.

Regards,
Andrejus

Anonymous said...

Hi,

i am new to ADF and BPEL

i followed your SOA example but i could not get it running and i have some questions i would like to ask

i deployed SalaryBonus process successfully and then i created Webservice control under UserInterface
so i could see process(integer,double,double)in the Data Control.

However, when looking at seachEmployees.jspx and updatEmployeeSalary.jspx in design view i could not see anything even the commandButton But when i looked into the code of two files there are some codes written already.
i was wondering why

Questions

1.do i need to drag the process(interger,double,double) into .jspx file to create the button and do i need to modify anything to get this example running.?

2. why i could not see anything in design view of both files?


3. Please provide the steps after the process of salaryBonus is in Data Control.


i was trying to run SearchEmployees.java and i got the error on the browser : JBO-30003

thank you in advance

Andrej Baranovskij said...

Hi,

You need to look into UpdateEmployeeSalary class. This backing bean contains action method associated with your mentioned button - updateSalaryButton_action(). From this method I'm invoking method in Data Control.

Regards,
Andrejus

Anonymous said...

Hi,

Can we invoke the same BPEL Service two times in the same page or from any other two pages?

Andrej Baranovskij said...

Sure it can be done !

Andrejus

cosmoghurl said...

hi,

i came across your blog while looking for sample -invoking BPEL process from ADF/WebCenter and this is a very good example. I'm new to the whole ADF/BPEL topics, and I'm wondering if you can provide steps for JDev 11g where I can call BPEL process once the button is hit. I tried migrating the zip file to my 11g but the page seems in error (all i can see in design view is < html >< button >)

thanks for your time!

Anonymous said...

hi Andrejus,
This is a very helpful blog.
I have an issue, when i am running the searchemployee.jspx page I am getting the following error Descriptor META-INF/HrDs-jdbc.xml not found.Can u please help me in resolving this.
Thanks
Anuj

Unknown said...

Hi Andrejus,

I have a similar ADF application calling a BPEL process. It works well when I launch the application from JDeveloper into INtegrated Weblogic. However when I deploy the application to a standalone instance, it gives a Port Exception error at the point where BPEL is being called. I checked a OTN discussion and it said I was missing WSM-PM.

Can you provide help on how to configure my application so that it does not need security and can by-pass WSM-PM.

Thanks
Raju