Wednesday 9 November 2011

Lesson13-Service Data Objects (SDO)

image

We have seen in previous articles how can be used in to write information to Database. 11g provides another method to implement Entity Services: Service Data Object ().
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 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 . 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:
  1. ADF-BC service adapter to send and receive messages from ADF BC service. 
  2. Create Entity and Bind Entity activities.
imageimage
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:
<reference name="OrderSDO"
           ui:wsdlLocation=http://192.160.1.5:7001/OrderSDOWebServices/OrderSDOService?WSDL>
  <interface.wsdl interface="http://www.orafmwschool.com/training/sdo/app/common/#wsdl.interface(OrderSDOService)"/>
  <binding.adf serviceName="{http://www.orafmwschool.com/training/sdo/app/common/}OrderSDOService"
               registryName="OrderSDOApplication_JBOServiceRegistry"/>
</reference>
Where
  • 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:fromExpression>bpws:getVariableData(‘inputVariable’)</bpelx:fromExpression>
</bpelx:createEntity>
<bpelx:bindEntity name="BindOrderEV" variable="OrderViewEV">
  <bpelx:key keyname="ns2:OrderId">bpws:getVariableData(‘inputVariable’,'parameters’,'/ns3:createOrafmwschoolOrdersView1/ns3:orafmwschoolOrdersView1/ns2:OrderId’)</bpelx:key>
</bpelx:bindEntity>
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.
<copy>
  <from variable="inputVariable" part="parameters"
        query="/ns3:createOrafmwschoolOrdersView1/ns3:orafmwschoolOrdersView1/ns2:CreatedBy"/>
  <to variable="OrderViewEV"
      query="/ns2:orafmwschoolOrdersViewSDO/ns2:CreatedBy"/>
</copy>
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:
  1. Order data services using ADF Business Components. Complete jdeveloper project can be downloaded from here.
  2. 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.
Data Objects
  • Create a new generic application called “OrderSDOApplication”.
SDO Application
  • In the next step, name the project “OrderBusinessComponents” and select “ADF Business Components” from the available project technologies.
Order Business Components Project
  • Right click on “OrderBusinessComponents”, select “New” and then “Business Components from Tables” from Business Tier section.
Order Business Components Project
  • Select FOD database connection in the next screen. If not already created, create a new connection to FOD schema.
DB Connection wizard DB Connection wizard
  • Click OK. From next screen, select ORAFMWSCHOOL_ORDERS, ORAFMWSCHOOL_ORDER_ITEMS tables.
Entity Objects
  • Select both views from next screen.
ADF BC Updateable Views
  • 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
ADF BC Summary Screen
  • This creates an Application Module, updateable view objects as well as corresponding relationships between tables.
ADF BC Summary Screen
Service Enable OrderSDO
  • Double click on OrderSDO to bring up properties page.
  • Select “Services Interface” option from the next screen.
SDO Service Interface
  • Click on “+” icon to create new service interface. Specify meaningful namespace.
ADF Service Interface
  • Click Next twice to arrive at Step 3.
  • Select OrfmwschoolOrdersView1 and OrafmwschoolOrderItemsView1. For each of these views, select all listed operations.
ADF Service Interface ADF Service Interface
  • Click Finish to generate Service Interface.
ADF Service Interface
  • Click on Configurations tab in the above screen and double click on OrderSDOService.
ADF Service Interface
  • 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.
ADF BC Service DB Connection ADF BC Service DB Connection
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”.
ADF BC Service Deployment
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.
ADF BC Service Deployment
  • Select Java EE Application and specify “OrderBCServices” for Webcontext root just to make the context name short. Click OK.
ADF BC Service Deployment
  • Right click on “OrderSDOApplication” and select Application Properties. Edit “OrderBusinessComponents_OrderBCProfile (EAR File)”. Specify “OrderSDO Application” as the name of application.
ADF BC Service Deployment
  • 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.
ADF BC Deployment
  • Select Listeners tab. Add a new service listener with class name “oracle.jbo.client.svc.ADFApplicationLifecycleListener”.
ADF BC Deployment
  • Right click on “OrderSDOApplication” and deploy to SOA Server.
ADF BC Deployment
  • JDeveloper would display successful deployment message along with URL to access web application as shown below.
image
  • Access URL http://<your_server_name>:port/OrderBCServices/OrderSDOService?WSDL to confirm successful deployment.
image
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 …


Lets build Order process to consumer Business Components we created in previous example through an entity variable.
  • Create an SOA project and name it “OrderSDOProcess”. Select Empty Composite from next screen and click Finish.
image image
  • Make a note of OrderSDO service WSDL we created in previous step. In my case,  it is http://192.168.0.5:7001/OrderBCServices/OrderSDOService?WSDL.
  • Drag and drop a BPEL Process component on to components section of composite.xml. Name it “OrderSDOProcess”. Select “Base on a WSDL” as template.
image
image
  • Double click on OrderSDOProcess in composite.xml to bring up BPEL process page.
image
  • Double click on receiveInput activity and select “createOrafmwschoolOrdersView1” as the input operation.
image
  • Next to Variable section, click on “+” icon to auto generate input variable. Click OK.
image
  • Receive these steps for “replyOutput” activity to select “createOrafmwschoolOrdersView1” operation and auto-create output variable. Click OK.
image
  • Drag and drop a ADF-BC Service adapter from BPEL Services section. Fill in values as shown below. As you may have observed, Registry key is of the form <ADF BC Application Name>_JBOServiceRegistry. In previous example, we named our ADF BC application – OrderSDOApp. Click OK to create partner link.
image
  • Let us create entity variable to use our SDO service. Drag and drop “Create Entity” activity below “receiveInput”.
image
  • Double click on CreateEntity_1 activity and click on Browse icon next to “Entity Variable” field.
image
  • Click on “+” icon to create new entity variable. Name it “OrdersViewEV” and select type as “Element”. Select orafmwschoolOrdersViewSDO as element value as shown below. Click OK.
image image
  • Associate this entity variable with OrderSDOService partner link as shown below from next step. Click OK in next subsequent screens to go back to “Create Entity” screen.
image image
  • Select “receiveInput_createOrafmwschoolOrdersView1_InputVariable” for From element as shown below.
image image
  • Click OK in “Create Entity” screen.
  • Drag and drop “Bind Entity” activity next to “Create Entity”.
  • Double click on “Bind Entity” and select OrdersViewEV as entity variable. Click OK.
image
  • Click “+” in Unique Keys section to select a unique key to bind to SDO entity variable. In our case it is going to be OrderId.
  • Select OrderId from OrdersViewEV variable for Key Local Part, as shown below.
image image
  • Similarly select “OrderId” from process input variable for “Key Value” field, as shown below.
image
image
  • Click OK to save and close “Bind Entity” dialog.
So far, we created an Order SDO service, created an entity variable to link to the SDO service and bound this variable using an unique key to the process input variable. Lets assign some values from process input variable to entity variable to complete the example.
  • Drag and drop an Assign activity between “CreateEntity_1” and “BindEntity_1”. Assign OrderId from process input variable SDO entity variable as shown below. Repeat this step for the elements of OrdersView and OrderItemsView.
image
  • Deploy and test the process.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...