Thursday, August 13, 2009

Service-Enabled Entity Objects in Oracle Fusion 11g

In Oracle Fusion 11g, JDeveloper provides great support for Application Integration Architecture (AIA) through Service-Enabled Entity Objects. It allows to build Enterprise Composite Applications (ECA) in Oracle ADF. Developer now can implement Entity Objects directly based on View Objects from remote application, exposed through Web Service. This means we can expose and consume Web Services on Model level using ADF Business Components, this gives more centralized integration approach. Its especially important for AIA, when building ECA. For more info, please read Section 11.3 Accessing Remote Data Over the Service-Enabled Application Module from Oracle Fusion Developer Guide. In this post I will describe some tips and tricks from my experience.

I have investigated Service-Enabled Entity Objects in greater detail and developed sample application. Sample is based on two JDeveloper 11g applications, first - SalaryUpdateRemote.zip is consuming remote Web Service on Entity Object level, second - SalaryControlService2.zip implements this Web Service. Application with Web Service implementation was developed in my previous post - Web Service Interface for ADF BC Application Module in Oracle Fusion 11g, where I have described how to expose through Web Service custom methods from Application Module implementation class. I have updated previously developed application in order to use it in current post, additionally have exposed View Object itself through Web Service.

I'm using Employees View Object from SalaryControlService application to be accessed through Web Service:


In SalaryControlService Application Module Service Interface, you can see EmployeesView1 exposed as View Instance:


I have declared three operations to be enabled for EmployeesView1. Find is required operation to retrieve data, Update operation will be used to edit employees data through remote Entity Object:


When Service Interface for View Object is defined, we can redeploy SalaryControlService. I have accessed redeployed application through Enterprise Manager console, updated list of operations is present now:


We need to note down WSDL URL, it will be needed soon, when we will define Entity based on Service Interface.

Its time to open application, where View Object is consumed over Web Service - SalaryUpdateRemote. Its pretty basic application:


Only one interesting thing - Employees Entity Object is based on Service Interface, we can see this from DataSource tag. This Entity Object is based on View Object exposed through Web Service, instead of Database table:


When you base Entity Object on Web Service interface, same as you generate it from Database table, all attributes are defined:


To create Entity Object based on Service Interface, in Create Entity Object wizard select Service Interface option for Data Source. You will be requested to provide WSDL URL for Web Service, available Service View Instances will be listed automatically:


All other steps are the same, as when creating Entity Object based on Database table. When I have created View Object referencing Service-Enabled Entity Object, I have noticed that Query section is empty:


Thats logical, because data will be retrieved on runtime through Web Service. However, this means that Service-Enabled Entity Objects can't participate in joins and can be used only as primary objects. For more info read Section 11.3.7 What You May Need to Know About Service-Enabled Business Component Restrictions from Oracle Fusion Developer Guide.

Finally, in order to test Service-Enabled functionality, as described in documentation you need to include common library from Web Service application:


And define service connection information in connections.xml file:


You can copy paste this information from Web Service application and just add couple parameters. In documentation they say we can access remote Web Service with Local or Remote Business Components Service configuration. Local can be used when Business Components Service runs local to the consuming application. However, I wasn't able to run with Local configuration, seems it was trying to load two Application Modules on Class Path and then conflicting. Good news, I was able to run with Remote configuration:


In jndiProviderURL I have specified IP and Port of my WebLogic domain extended with SOA support.

Now its time to run Application Module and test Service-Enabled Entity functionality:


Because I have enabled Find and Update operations, I can browse and edit data retrieved from Web Service View Object instance:


I have developed ViewController part as well, where I have implemented simple edit type form for Employees data. Finally, I have deployed application with Service-Enabled Entity Object to the same WebLogic domain with SOA support, where original ADF BC Web Service was deployed. I have noticed, if you want to use Service-Enabled Entity Object in ViewController, common library from Web Service application should be added to ViewController classpath:


But its not enough, additionally you should open deployment profile and in WEB-INF/lib Contributors section ensure that added common library is selected for deployment:


If its not selected, this means it will be not packaged into EAR there will be runtime exception when trying to access Web Service through Entity Object.

When SalaryUpdateRemote application is deployed:


We can access main page and retrieve Employees information through remote Web Service directly using ADF Business Components. Data can be edited and saved to database through Web Service:


Its very interesting and useful functionality, if there will be decision to implement Salary attribute validation rule, there is no need to implement it on Service-Enabled Entity:


It can be done directly on original Entity Object available in ADF Business Components exposed through Web Service - SalaryControlService application:


Data from consuming application will be sent to Web Service and validated there centrally. In case of invalid data, remote application will show error:


Spanish Summary:

Este post ofrece un ejemplo de una nueva caracteristica que ofrece Jdeveloper para permtir la creacion de entidades en base a ViewObjects que pertenecen a aplicaciones remotas, las cuales son accedidas por medio de WEB Services. De esta manera nuestras aplicaciones pueden implementar rápidamente Enterprise Composite Applications (ECA) usando ADF.

6 comments:

aaroy said...

Nice post Andrejus. The article has been inspiring indeed. I was wondering what would be the solution if we were to use Webservices's WSDL only that are not from SDOs.

Would WSDatacontrols be the only solution?

Thanks,
Ansuman

Palanivel Muthugounder said...

it is really nice one , which one solved my problem ... thanks man

Regards,
Palanivel

Anonymous said...

Not sure how this is really useful... Wow! you can have an Oracle Web Service client talk to an Oracle web service! Not useful... Please provide an example that backs an Entity Object with a service that provides a complex return from something other than an Oracle service. That would be more helpful and a real world use case... this is a toy use case.

Andrejus Baranovskis said...

Firstly you should learn to be polite and then start commenting. This is my person blog and I post use cases I'm interested in and believe they will be useful to others. This specific use case describes how to expose and integrate ADF BC through Web Service across your system application.

Regards,
Andrejus

Đặng Việt Hà said...

Hi Andrej,

I'm trying to use service-enabled entity object and view object but when bindings data to a table then we cannot use the built-in QBE functions (filtering/sorting) of the adf table. It display the NullPointerException on the screen and the output log as below:

ViewCriteriaImpl.addToGroup(ViewCriteriaImpl:76)
.....


Do you have any suggestion to resolve this problem? Thank you!

Đặng Việt Hà said...

the filtering had problem with ADF 11.1.2.2 and no problem with 11.1.2.4 but the sorting doesn't work in both version even with the latest version of ADF, 12.1.3. We need a work-around for the sorting on the table that get data from service-enable objects.