Pages

Friday, May 16, 2008

Using sdo web services with service based entities (ADF BC)

If you ever need to make a web application build on services ( because of SOA or it has to be demilitarized zone application) then you can use the new service based entity and view of ADF BC. With this it is easy to make a service based application and there are no differences with normal ADF database development.
ADF BC can also create the sdo web service for you. You can use this service not only for ADF BC but also for the new soa suite 11g. It can be an alternative for the the database adapter See my previous blog for more details. In this blog entry I will show you how to create a adf bc sdo web service and use this service in an other application.
With 11g you can easily create a SDO web service. You only have to create a bc4j model project and add an entity with a viewobject. The viewobject which you want to service has to be added to the applicationmodule. The only thing you have to do now is open the applicationmodule and add a new service interface.

Add the viewobject and select the wanted operations on this viewobject

When it finishes you see JDeveloper generates a few xml schema's and java classes.
To test the new service run the ServiceImpl of the application module. This class is located in the serviceinterface package.
We have to make a ADF BC service deployment profile.


We can deploy the service to the local j2ee server. First start the oc4j container with JDEV_HOME/binoc4j.cmd -start. create a application server connection in your project and deploy this to this container. We have know two things, first we need our deployment profile name, this is CustomerService plus we add __MiddleTier. In my case the jndi lookup name will be CustomerService_MiddleTier. The second thing is the wdsl url this is http://localhost:8888/oe_sdo_service-model-context-root/CustomerModuleService?WDSL .
We are almost ready with sdo web service we only have to copy the reference from the connection.xml


Create a new fusion application where we add the just copied reference entry to this application connection.xml plus we add a few extra jndi entries

<?xml version = '1.0' encoding = 'UTF-8'?>
<ns2:References xmlns:ns2="http://xmlns.oracle.com/adf/jndi">
<Reference className="oracle.jbo.client.svc.Service" name="{/nl/ordina/sdo/service/common/}CustomerModuleService">
<Factory className="oracle.jbo.client.svc.ServiceFactory"/>
<RefAddresses>
<StringRefAddr addrType="serviceInterfaceName">
<Contents>nl.ordina.sdo.service.common.serviceinterface.CustomerModuleService</Contents>
</StringRefAddr>
<StringRefAddr addrType="serviceEndpointProvider">
<Contents>ADFBC</Contents>
</StringRefAddr>
<StringRefAddr addrType="jndiName">
<Contents>nl.ordina.sdo.service.common.CustomerModuleServiceBean</Contents>
</StringRefAddr>
<StringRefAddr addrType="jndiFactoryInitial">
<Contents>oracle.j2ee.rmi.RMIInitialContextFactory</Contents>
</StringRefAddr>
<StringRefAddr addrType="jndiProviderURL">
<Contents>ormi://localhost:23791/CustomerService_MiddleTier</Contents>
</StringRefAddr>
<StringRefAddr addrType="jndiSecurityPrincipal">
<Contents>fmwadmin</Contents>
</StringRefAddr>
<StringRefAddr addrType="jndiSecurityCredentials">
<Contents>welcome</Contents>
</StringRefAddr>
<StringRefAddr addrType="serviceSchemaName">
<Contents>CustomerModuleService.xsd</Contents>
</StringRefAddr>
<StringRefAddr addrType="serviceSchemaLocation">
<Contents>nl/ordina/sdo/service/common/serviceinterface/</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
</ns2:References>

Add the CustomerService_Common.jar to the project library. This jar is located in the deploy folder.
Finally we can create a entity based on a service. Create a new entity and select the service option where we add the ws wdsl url

And we can create in the last step an application and a viewobject.
Now start the bc4j tester by running the applicationmodule and we see all the customers.

We can use this application module in our jsf application.

4 comments:

  1. Hi,

    It is standaard how data is structured and how it is retrieved. So you can use in Oracle for example sap sdo ws. You can use it directly

    The Service Data Objects framework provides a unified framework for data application development. With SDO, you do not need to be familiar with a technology-specific API in order to access and utilize data. You need to know only one API, the SDO API, which lets you work with data from multiple data sources, including relational databases, entity EJB components, XML pages, Web services, the Java Connector Architecture, JavaServer Pages pages, and more.

    for more info, ibm has a lot of papers about it
    http://www.ibm.com/developerworks/java/library/j-sdo/

    ReplyDelete
  2. Hi,

    is there also a way of doing this in 10g? I'm currently trying to create a POC application where the whole model layer is based on web services.

    Thanks,

    Koen Verhulst

    ReplyDelete
  3. Hi Sorry this is only working in the next version of 11g.

    But you can create adf bc web service and you have to create proxy web services on this after that you can generate datacontrols.

    Or if you use adf bc then you can make a ejb deployment. Ok this is not ws but it uses rmi.

    Is web service interface necessary or can you use rmi

    thanks Edwin

    ReplyDelete