Monday, July 18, 2011

Leveraging SDOs in BPM11g

In this simple scenario we will process orders that adhere to the following XSD

btw. a great resource that I often refer to is Antony Reynolds/Matt Wright --> Oracle SOA Suite 11g Developers Guide. If you don't already have it - then get it!

Ok back to business...



The underlying DB tables are as follows (I've created them in SCOTT's schema)–



DDL is available at Appendx A

Scenario
We are used to having payloads that contain all of the order attributes. We can imagine an Order Entry UI where the Order & customer details are entered. We could pass all of this on to BPM via the payload. However a more efficient way may be to leverage SDOs and just pass the keys e.g. OrderId, CustID on to BPM. BPM can then load the data in just in time mode from the DB using the SDO.

Setup
You need to have your DB schema installed. I create 1 customer so that I’ve something to test.



Create an ADF App in JDeveloper
This app will contain ADF-BC artifacts that we will expose via a Service Interface.



Set App name in project properties to something more readable as the default.



Create a BC App Module based on the tables we created.







Open the AppModule and click on Service Interface, then the +







Do the same for the other views.

FYI: Here is an extract from the official docs, detailing the operations.






The following files are generated



Test

We can test the SDO using OrdersAMServiceImpl




Running this app will deploy it to the integrated WLS and open the test page in your browser.
Select the getAmCustomerView1 operation
- Enter 1 as the cust id






Deploy to SOA Admin Server
Change the wsdl url to point to the target port
- Per default it is generated for 7101 (the JDev integrated WLS).



Add the following to the weblogic-application.xml






This enables us to register the SDO as an RMI Service.

The Datasource used by ADF-BC (jdbc/scottDS) needs to be XA aware.
The default generated/deployed by ADF-BC is not what we require, so we have to do 2 things - de-activate auto-generation of the weblogic-jdbc.xml and create the necessary datasource on our target WLS.




Using the WLS console, create a datasource jdbc/scottDS.
Per default it will be XA aware.

Create a new deployment profile of type Business Components Service Interface




Give the application a more meaningful name



Deploy from the Application Menu




Test



Leverage SDO in a BPM Composite

Create a BPM app



In Composite.xml --> add an ADF-BC Service (Reference).



Note: Registry name set to ADF app name + _JBOServiceRegistry.



Now we add a FileAdapter(ReadOrders) which will pass in the custID.
In the BPM designer, set Start implementation to ReadOrders.



Add a Service activity to retrieve the customer from the DB.





Deploy & test






Appendix A

ALTER TABLE AM_PRODUCT
DROP CONSTRAINT AM_PRODUCT_AM_ORDER_LINE_FK;

ALTER TABLE AM_ORDER_LINE
DROP CONSTRAINT AM_ORDER_LINE_AM_ORDER_FK;

ALTER TABLE AM_ORDER
DROP CONSTRAINT AM_ORDER_AM_CUSTOMER_FK;

DROP TABLE AM_PRODUCT CASCADE CONSTRAINTS;

DROP TABLE AM_ORDER_LINE CASCADE CONSTRAINTS;

DROP TABLE AM_ORDER CASCADE CONSTRAINTS;

DROP TABLE AM_CUSTOMER CASCADE CONSTRAINTS;

CREATE TABLE AM_PRODUCT
(
PRODUCT_ID VARCHAR2(20) NOT NULL
, PRODUCT_NAME VARCHAR2(20) NOT NULL
, PRODUCT_PRICE DECIMAL NOT NULL
, PRODUCT_DESCRIPTION VARCHAR2(255)
, ORDER_LINE_ID VARCHAR2(20)
, CONSTRAINT AM_PRODUCT_PK PRIMARY KEY
(
PRODUCT_ID
)
ENABLE
);

CREATE TABLE AM_ORDER_LINE
(
ORDER_LINE_ID VARCHAR2(20) NOT NULL
, ORDER_LINE_ITEM_DISCOUNT DECIMAL NOT NULL
, ORDER_LINE_ITEM_QUANTITY NUMBER NOT NULL
, ORDER_ID VARCHAR2(20)
, CONSTRAINT AM_ORDER_LINE_PK PRIMARY KEY
(
ORDER_LINE_ID
)
ENABLE
);

CREATE TABLE AM_ORDER
(
ORDER_ID VARCHAR2(20) NOT NULL
, ORDER_STATUS VARCHAR2(20) NOT NULL
, ORDER_DISCOUNT DECIMAL
, ORDER_COMMENTS VARCHAR2(255)
, CUST_ID VARCHAR2(20)
, CONSTRAINT AM_ORDER_PK PRIMARY KEY
(
ORDER_ID
)
ENABLE
);

CREATE TABLE AM_CUSTOMER
(
CUST_ID VARCHAR2(20) NOT NULL
, CUST_NAME VARCHAR2(20) NOT NULL
, CUST_EMAIL VARCHAR2(20) NOT NULL
, CUST_CREDITCARD_TYPE VARCHAR2(20) NOT NULL
, CUST_CREDITCARD_NR VARCHAR2(20) NOT NULL
, CONSTRAINT AM_CUSTOMER_PK PRIMARY KEY
(
CUST_ID
)
ENABLE
);

ALTER TABLE AM_PRODUCT
ADD CONSTRAINT AM_PRODUCT_AM_ORDER_LINE_FK FOREIGN KEY
(
ORDER_LINE_ID
)
REFERENCES AM_ORDER_LINE
(
ORDER_LINE_ID
)
ENABLE;

ALTER TABLE AM_ORDER_LINE
ADD CONSTRAINT AM_ORDER_LINE_AM_ORDER_FK FOREIGN KEY
(
ORDER_ID
)
REFERENCES AM_ORDER
(
ORDER_ID
)
ENABLE;

ALTER TABLE AM_ORDER
ADD CONSTRAINT AM_ORDER_AM_CUSTOMER_FK FOREIGN KEY
(
CUST_ID
)
REFERENCES AM_CUSTOMER
(
CUST_ID
)
ENABLE;

1 comment:

  1. Hi,

    This site seems to be very informative.It had cleared my issues regarding oracle enterprise.Thanks for sharing this.

    Oracle R12 Upgrade.

    ReplyDelete