We have seen in previous articles how DB Adapter can be used in SOA Suite to write information to Database. SOA Suite 11g provides another method to implement Entity Services: Service Data Object (SDO).
SDO provides a unified interface to access datasource, irrespective of its type, from SOA composite. This is achieved by creating Data Services with the help of ADF Business Components. At the outset, it may sound no different from previous methods. However, the difference is that the data can be accessed with the help of an entity variable within BPEL. Data is synchronized with external updates as well. Nested objects are also supported. In addition, we can enable RMI communication instead of SOAP to improve performance.
BPEL provides three constructs for this purpose:
- ADF-BC service adapter to send and receive messages from ADF BC service.
- Create Entity and Bind Entity activities.
ADF-BC Service will let process bind to an existing ADF Business Component service layer. Once ADF BC service reference is successfully created, composite.xml will contain following XML fragment:
- wsdlLocation points to webservices exposed by ADF Business Component Application.
- registryName is constructed using <ADF BC Application Name>_JBOServiceRegistry. In the above example, OrderSDOApplication is ADF application name. This key is automatically generated and is used to look up SDO through RMI.
XML fragment shown below contains “OrderViewEV” entity variable, bound to SDO using unique key – “orderId”.
<bpelx:createEntity name="CreateOrderEV" variable="OrderViewEV">
<bpelx:bindEntity name="BindOrderEV" variable="OrderViewEV">
Once entity variable is successfully created and bound to SDO, any operation performed on the entity variable will transparently invoke appropriate ADF BC service. For example, following copy activity will transparently update CreatedBy column in ORDERS table.
<from variable="inputVariable" part="parameters"
In this tutorial, we will create an OrderSample BPEL process that creates Orders and Order Items in database with the help of SDO and ADF Business Components. We’ll implement this example in two parts:
- Order data services using ADF Business Components. Complete jdeveloper project can be downloaded from here.
- Order BPEL process that uses Order data services through SDO entity variable.
1. Create Order data services using ADF Business Components
- Create a new schema called “FOD”. Run dataobjects.sql to create tables as shown below.
- Create a new generic application called “OrderSDOApplication”.
- In the next step, name the project “OrderBusinessComponents” and select “ADF Business Components” from the available project technologies.
- Right click on “OrderBusinessComponents”, select “New” and then “Business Components from Tables” from Business Tier section.
- Select FOD database connection in the next screen. If not already created, create a new connection to FOD schema.
- Click OK. From next screen, select ORAFMWSCHOOL_ORDERS, ORAFMWSCHOOL_ORDER_ITEMS tables.
- Select both views from next screen.
- Accept default values in “Read-Only View Objects” and click on Next.
- Specify “OrderSDO” as the name of Application Module. Click Next in subsequent screens to arrive at Summary screen and click on Finish
- This creates an Application Module, updateable view objects as well as corresponding relationships between tables.
Service Enable OrderSDO
- Double click on OrderSDO to bring up properties page.
- Select “Services Interface” option from the next screen.
- Click on “+” icon to create new service interface. Specify meaningful namespace.
- Click Next twice to arrive at Step 3.
- Select OrfmwschoolOrdersView1 and OrafmwschoolOrderItemsView1. For each of these views, select all listed operations.
- Click Finish to generate Service Interface.
- Click on Configurations tab in the above screen and double click on OrderSDOService.
- By default, ADF Business Components use Managed Datasource available in Weblogic Server. Name of datasource is of format java:comp/env/jdbc/<DB_Connection_Name>DS. In this example, it is “java:comp/env/jdbc/FODDS”.
- Enable direct JDBC connectivity instead of using Managed Datasource. From connection type, select “JDBC URL” and leave default values. This is only for this example purpose. In production systems, using Managed Datasource is recommended.
Enable Master Detail relationship
To enable OrderSDO to process OrderItemsSDO, we need to set SERVICE_PROCESS_CHILDREN property to true in the mastser-detail association link.
- Double click on OrafmwschoolOrderItemsFk1Assoc.xml to bring up properties page. Add custom property with name: “SERVICE_PROCESS_CHILDREN” and value: “true”.
Create Deployment Profiles for Project and Application
Right click on OrderBusinessComponents project to bring up project properties page. Click on “Deployment” and then “New” to create a new deployment profile. Specify “Business Components Services Archive” for archive type and specify “OrderBCProfile” as name. Click OK.
- Select Java EE Application and specify “OrderBCServices” for Webcontext root just to make the context name short. Click OK.
- Right click on “OrderSDOApplication” and select Application Properties. Edit “OrderBusinessComponents_OrderBCProfile (EAR File)”. Specify “OrderSDO Application” as the name of application.
- We can now right click on “OrderSDOApplication” and deploy Business Components to SOA Server. This would create webservices with operations we selected in previous steps. These webservices will use standard SOAP protocol. However, in order to create transactional services, we will have to enable RMI as communication protocol.
- Application name in previous step will be used later in part-2 of this article to construct RMI lookup key: OrderSDOApp_JBOServiceRegistry.
- From Application Navigator, select weblogic-application.xml as shown below.
- Select Listeners tab. Add a new service listener with class name “oracle.jbo.client.svc.ADFApplicationLifecycleListener”.
- Right click on “OrderSDOApplication” and deploy to SOA Server.
- JDeveloper would display successful deployment message along with URL to access web application as shown below.
- Access URL http://<your_server_name>:port/OrderBCServices/OrderSDOService?WSDL to confirm successful deployment.
Complete jdeveloper project can be downloaded from here..
Part-2 of this example deals with using SDO in BPEL with the help of BC Adapter and Entity Variables. Stay tuned …