Contents
This is part of the Oracle SOA11g hands on tutorials.
Overview
* SDO is a standard defined by Open SOA consortium.
* SDO is an abstraction layer for accessing heterogeneous data sources.
* SDO supports both static (e.g. entity bean) and dynamic (e.g. JDBC) data APIs.
* SDO supports disconnected programming models, i.e. disconnected data graphs. Data Access Service handles data access functions such as CRUD.
* SDO is language neutral.
* SOA 11g supports SDO via a new BPEL component called Entity Variables. Entity Variables relies on ADF-BC for data access service.
Prepare Database Table
* Login soademo schema from SQL*Plus and execute the following SQL statements to create a new CUSTOMERS table.
CREATE TABLE CUSTOMERS ( CUSTOMER_ID VARCHAR2(10) NOT NULL PRIMARY KEY, CUSTOMER_NAME VARCHAR2(255) NOT NULL, LAST_ORDER_NUMBER VARCHAR2(4000), LAST_ORDER_AMOUNT NUMBER(10,2) ); INSERT INTO CUSTOMERS VALUES ('1111', 'Test Customer', NULL, NULL); COMMIT;
Create ADF-BC Service
Create an ADF-BC Application
* Open JDev.
* Click File -> New to open the New Gallery dialog.
* Select General -> Applications -> Generic Application.
* Click OK to open Create Generic Application dialog.
– Name: CustomerSDOApp
– Directory: C:\po\CustomerSDOApp
– Package Prefix: customerapp
* Click Next to go to the Name Your Project dialog.
– Project Name: CustomerSDO
– Directory: C:\po\CustomerSDOApp\CustomerSDO
– Project Technologies: ADF Business Components
* Click Finish.
* Save all.
Create Business Components
* Right click CustomerSDO project and select New… to open the New Gallery dialog.
* Select Business Tier -> ADF Business Components -> Business Components from Tables and click OK.
* On Initialize Business Components Project dialog, click the green plus icon to open the Create Database Connection dialog.
– Connection Name: soademo-jdev
– Connection Type: Oracle(JDBC)
– Username: soademo
– Password: soademo
– Host Name: localhost
– SID: orcl
* Click Test Connection button and make sure “Success!” message is returned.
* Click OK.
* Accept default SQL Flavor and Type Map (both Oracle) and click OK.
* On Entity Objects dialog,
– Click Query button.
– Move CUSTOMERS table from Available to Selected. Click Next.
* On Updatable View Objects dialog,
– Move CUSTOMERS table from Available to Selected. Click Next.
* Click Next on Read-Only View Objects dialog.
* On Application Module dialog, enter
– Name: CustomerSDOAppModule
– Click Next.
* Click Finish.
* Save all.
Testing Application Module
* Right click CustomerSDOAppModule (CustomerSDO project -> Application Sources -> customerapp -> CustomerSDOAppModule) and select Run.
* On Java application, double click CustomersView1.
* Close Java application by clicking File -> Exit.
Create Service Interface
* Double click CustomerSDOAppModule to open CustomerSDOAppModule.xml file.
* Click Service Interface on the left pane.
* Click green plus sign to open Create Service Interface dialog.
* On Service Interface dialog:
– Web Service Name: CustomerSDOService
– Target Namespace: /customerapp/common/
* Click Next twice to go to Service View Instances.
– Move CustomersView1 from Available to Selected.
– Select CustomersView1 in the Selected list and then select all operations listed under Basic Operations tab (don’t forget to scroll down).
* Click Finish.
* Save all.
Deploy Application Module
Configure Module
* Double click CustomerSDOAppModule to open CustomerSDOAppModule.xml file.
* Click Configurations on the left pane.
* Select CustomerSDOService as the Default Configuration.
* Double click CustomerSDOService to open Edit Business Components Configuration dialog and set:
– Datasource Name: jdbc/soademoDatabase
* Click OK.
* Save all.
Set Web App Name and Context Root
* Right click CustomerSDO project and select Project Properties.
* Select Java EE Application in the left side panel and set:
– Java EE Web Application Name: CustomerSDO-webapp
– Java EE Web Context Root: customer-app
* Click OK.
Create Deployment Profile
* Right click CustomerSDO project and select Project Properties.
* Select Deployment in the left side panel.
* Click New… to open Create Deployment Profile dialog.
– Archive Type: Business Components Service Interface
– Name: customerSDOProfile
* Click OK to close Create Deployment Profile dialog.
* Back on Project Properties dialog.
* Expand customerSDOProfile and select MiddleTier.
* Click Edit… to open Edit EJB JAR Deployment Profile Properties dialog and set:
– EJB JAR File: C:\po\CustomerSDOApp\CustomerSDO\deploy\customerSDO-app.jar
– EAR File: C:\po\CustomerSDOApp\CustomerSDO\deploy\customerSDO-app.ear
– Enterprise Application Name: customerSDO
* Click OK twice to close Project Properties dialog.
* Save all.
Set Application Name
* Select CustomerSDO project.
* Select Application -> Application Properties… from JDev menu bar to open Application Properties dialog. Note: don’t select Project Properties…
* Click Deployment on left side panel.
* Select CustomerSDO_customerSDOProfile (EAR File) and click Edit… button.
* Set:
– Application Name: CustomerSDOApp
* Click OK on both dialogs.
* Save all.
Setup WebLogic Life Cycle Listener
* In Application Resources pane, double click Descriptors -> META-INF -> weblogic-application.xml to open it.
* Click Listeners on the left side pane.
* Click green plus sign to add a new listener row.
* Enter class name:
oracle.jbo.client.svc.ADFApplicationLifecycleListener
* Hit Enter key.
* Save all.
Deploy
* Select CustomerSDO project.
* From JDev menu bar, select Application -> Deploy -> CustomerSDO_customerSDOProfle to open Deploy CustomerSDO_customerSDOProfle dialog.
* Select Deploy to Application Server and click Next.
* Select MyAppServerConnection and click Next.
* Select Deploy to selected instances in the domain and then select soa_server1 and click Next.
* Click Finish.
Test Customer SDO Service
* Point browser to http://localhost:8001/customer-app/CustomerSDOService
* Or from EM, navigate to FARM_soa_domain -> Application Deployments -> CustomerSDOApp (soa_server1) and click Test icon in the Web Service pane.
* Select Operation: getCustomersView1
* Enter:
– customerId: 1111
* Click Invoke button on the bottom of the page.
* Check that response contains:
– CustomerName: Test Customer
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/><env:Body> <ns0:getCustomersView1Response xmlns:ns0="/customerapp/common/types/"> <ns1:result xmlns:ns1="/customerapp/common/types/" xmlns:ns0="/customerapp/common/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:CustomersViewSDO"> <ns0:CustomerId>1111</ns0:CustomerId> <ns0:CustomerName>Test Customer</ns0:CustomerName> <ns0:LastOrderNumber xsi:nil="true"/> <ns0:LastOrderAmount xsi:nil="true"/> </ns1:result> </ns0:getCustomersView1Response> </env:Body> </env:Envelope>
Using ADF-BC Service in POProcessing Composite Application
Add CustomerSDOService Reference
* Drag and drop ADF-BC Service component onto External References lane. This opens Create ADF-BC Service dialog.
* Enter:
– Name: CustomerSDOService
– Type: Reference
– WSDL: http://localhost:8001/customer-app/CustomerSDOService?WSDL
– PortType: CustomerSDOService
– Registry: CustomerSDOApp_JBOServiceRegistry
Note: the registry value should be AppName_JBOServiceRegistry. In this case, our application name is CustomerSDOApp. Therefore, the registry value is CustomerSDOApp_JBOServiceRegistry.
* Click OK.
Wire approveLargeOrder BPEL Process to CustomerSDO Service
* Drag a wire from lower right corner of approveLargeOrder BPEL Process to upper left corner of CustomerSDO reference.
* Save all.
Use SDO in BPEL
* Double click approveLargeOrder BPEL process.
* Click Variable icon (x) on the main approveLargeOrder scope.
* Click green plus sign to open Create Variable dialog. Enter:
– Name: CustomerInfoEV
– Type -> Element: {/customerapp/common/}customersViewSDO.
Click magnifying glass to open Type Chooser dialog. Select Type Explorer -> Project WSDL Files -> CustomerSDOServiceWrapper.wsdl -> Imported WSDL -> CustomerSDOService -> Inline Schemas -> Schema -> customersViewSDO.
– Checked: Entity Variable
– Partner Link: CustomerSDOService
– SDO Capable: unchecked
* Click OK twice to exit Create Variable dialog.
Bind Primary Key
* Drag and drop a Bind Entity activity just after the receiveInput activity.
* Double click to open Bind Entity dialog.
– Name: BindCustomerId
– Entity Variable: CustomerInfoEV
* Click green plus sign to the right of Unique Keys to open Specify Key dialog.
* Click (x) icon to the right of Key Local Part to open Browse Entity Variable dialog.
* Select Variables -> Process -> Variables -> CustomerInfoEV -> customersViewSDO -> CustomerId
* Click function icon to the right of Key Value to open Expression Builder.
* Select inputVariable -> payload -> Order -> customerId and click OK.
– Key Value: bpws:getVariableData(‘inputVariable’,’payload’,’/ns2:Order/ns2:customerId’)
* Click OK again on Specify Key dialog.
* Click OK on Bind Entity dialog.
Get Customer Name from Entity Variable
* Drag and drop an Assign activity right below BindCustomerId activity. Rename it to AssignCustomerName.
* Double click new Assign activity icon to open Edit Assign dialog.
* Copy CustomerInfoEv -> customersViewSDO -> CustomerName to inputVariable -> payload -> OrderType -> customerId.
* Click OK
Assign Last Order
* Drag and drop an Assign activity under taskSwitch icon of ManualApproval1. Rename it AssignLastOrder.
* Double click to open Edit Assign dialog.
* Copy outputVariable -> payload -> Order -> OrderId to CustomerInfoEV -> CustomersViewSDO -> LastOrderNumber
* Copy bpws:getVariableData(‘outputVariable’,’payload’,’/ns2:Order/ns2:price’) * bpws:getVariableData(‘outputVariable’,’payload’,’/ns2:Order/ns2:qty’) to CustomerInfoEV -> CustomersViewSDO -> LastOrderAmount.
* Save all.
Test
* Redeploy POProcessing.
* Test input message with an order between 1000 and 5000:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body xmlns:ns1="http://xmlns.oracle.com/ns/order"> <ns1:PurchaseOrder> <ns1:CustID>1111</ns1:CustID> <ns1:ID>1212</ns1:ID> <ns1:productName>HD TV</ns1:productName> <ns1:itemType>Electronics</ns1:itemType> <ns1:price>900</ns1:price> <ns1:quantity>10</ns1:quantity> <ns1:status>Initial</ns1:status> <ns1:ccType>Mastercard</ns1:ccType> <ns1:ccNumber>1234-1234-1234-1234</ns1:ccNumber> </ns1:PurchaseOrder> </soap:Body> </soap:Envelope>
* Check that customerId field from the callbackClient component has been changed to Test Customer (not 111).
* Login database as soademo and check that LAST_ORDER_NUMBER and LAST_ORDER_AMOUNT fields have been updated to reflect the new order input message.
CUSTOMER_I CUSTOMER_NAME LAST_ORDER_NUMBER LAST_ORDER_AMOUNT ---------- -------------------- -------------------- ----------------- 1111 Test Customer 1212 9000
Issues
Could not find registry for CustomerApp_JBOServiceRegistry
Cause
* Wrong registry value (CustomerApp_JBOServiceRegistry) was used for CustomerSDOService in the composite.
* SDO application name is CustomerSDOApp, so the registry value should be CustomerSDOApp_JBOServiceRegistry.
Fix
* Change CustomerSDOService component’s registry value:
Registry: CustomerSDOApp_JBOServiceRegistry
One Response to SOA 11g Tutorial: Service Data Objects (SDO)