Skip Headers
Oracle® Fusion Applications Developer's Guide
11g Release 1 (11.1.3)

Part Number E15524-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

42 Synchronously Invoking an ADF Business Components Service from an Oracle ADF Application

This chapter describes what to do when you need to invoke an ADF Business Components service either from an ADF Business Components object or from a UI. Use only with synchronous processes with an immediate response.

When to implement: When you need to invoke an ADF Business Components service either from an ADF Business Components object or from a UI. Use only with synchronous processes with an immediate response.

Design Pattern Summary: Use ServiceFactory to generate a dynamic proxy to the target ADF Business Components service, then use the proxy to invoke the desired service method.

Involved components:

42.1 Introduction to the Recommended Design Pattern

When you need to invoke an ADF Business Components service from an Oracle ADF application, use oracle.jbo.client.svc.ServiceFactory to invoke the service.

42.2 Potential Approaches

One alternative is to use JAX-WS to generate static proxy classes. This is prohibited for ADF Business Components services because:

The other alternative is to use a dynamic invocation interface. This is not recommended as it requires much more coding.

If you need to bind the input or output of the service to UI components, consider using service-based entity objects and view objects. For more information, see Chapter 40, "Working with Data from a Remote ADF Business Components Service."

42.3 Example

Currently, no example is available.

42.4 How to Invoke an ADF Business Components Service from an Oracle ADF Application

On the service provider side, you must create an ADF Business Components service interface deployment profile. This profile generates two JAR files: one common JAR file that contains only the service interface, and another file that contains the implementation. For more information, see the chapter "Integrating Service-Enabled Application Modules" in Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

To invoke an ADF Business Components service from an Oracle ADF application:

  1. Navigate to Application Resources > Descriptors > ADF META-INF and open the connections.xml file.

    This entry is needed to invoke the service during runtime.

    Note:

    The targeted service must be hosted and running, as registration requires the URL of the service deployment location.

  2. Register the targeted service in connections.xml, as shown in Example 42-1.

    Example 42-1 Sample Code for the File connections.xml

    <Reference name="{http://xmlns.oracle.com/apps/adfsvc/deptempService/}DeptEmpService"
          className="oracle.jbo.client.svc.Service" xmlns="">
          <Factory className="oracle.jbo.client.svc.ServiceFactory"/>
          <RefAddresses>
             <StringRefAddr addrType="serviceInterfaceName">
                <Contents>oracle.apps.adfsvc.deptempService.DeptEmpService</Contents>
             </StringRefAddr>
             <StringRefAddr addrType="serviceEndpointProvider">
                <Contents>ADFBC</Contents>
             </StringRefAddr>
             <StringRefAddr addrType="jndiName">
               <Contents>DeptEmpServiceBean#oracle.apps.adfsvc.deptempService.DeptEmpService
    </Contents>
             </StringRefAddr>
             <StringRefAddr addrType="serviceSchemaName">
                <Contents>DeptEmpService.xsd</Contents>
             </StringRefAddr>
             <StringRefAddr addrType="serviceSchemaLocation">
                <Contents>oracle/apps/adfsvc/deptempService/</Contents>
             </StringRefAddr>
             <StringRefAddr addrType="jndiFactoryInitial">
                <Contents>weblogic.jndi.WLInitialContextFactory</Contents>
             </StringRefAddr>
             <StringRefAddr addrType="jndiProviderURL">
                <Contents>t3://localhost:7101</Contents>
             </StringRefAddr>
          </RefAddresses>
       </Reference>
    
  3. Get the service interface common JAR file from the service provider and add it to your library.

    This file is required during runtime. The common JAR file is generated when the service provider uses a ADF Business Components service interface deployment profile for deployment.

    For more information, see the chapter "Integrating Service-Enabled Application Modules" in Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

  4. In your ADF Business Components service or managed Java bean class, invoke the desired service using ServiceFactory, as shown in Example 42-2.

    Example 42-2 ServiceFactory Code

    OrganizationService svc =
               (OrganizationService)ServiceFactory.getServiceProxy(OrganizationService.NAME);
            List orgs = new ArrayList(2);
            Org org1 = (Org)DataFactory.INSTANCE.create(Org.class);
            org1.setOrganizationId(new Long(10000));
            org1.setOrgName("OrgName");
            org1.setName("TranslatedName");
            org1.setDescription("Your org Description"); //... and set more attributes
            orgs.add(org1);
            svc.processOrganizatiion("Merge", orgs, null);
    

    Sample queries are shown in Example 42-3.

    Example 42-3 Query Samples

    // Retrieve only Dname, Loc from Dept and exclude Empno from Emp.
            DeptEmpService mSvc = (DeptEmpService)ServiceFactory.getServiceProxy(DeptEmpService.NAME);
            FindCriteria fc = (FindCriteria)DataFactory.INSTANCE.create(FindCriteria.class);
            List l = new ArrayList();
            l.add("Dname");
            l.add("Loc");
            l.add("Emp");
            fc.setFindAttribute(l);
            List cfcl = new ArrayList();
            ChildFindCriteria cfc =           (ChildFindCriteria)DataFactory.INSTANCE.create(ChildFindCriteria.class);
            cfc.setChildAttrName("Emp");
            List cl = new ArrayList();
            cl.add("Empno");
            cfc.setFindAttribute(cl);
            cfc.setExcludeAttribute(true);
            cfcl.add(cfc);
            fc.setChildFindCriteria(cfcl);
            DeptResult res = mSvc.findDept(fc, null);
     
            // Exclude PurchaseOrderLine from PurchaseOrder.
            PurchaseOrderService svc =
                (PurchaseOrderService )ServiceFactory.getServiceProxy(PurchaseOrderService .NAME);
            FindCriteria fc = (FindCriteria)DataFactory.INSTANCE.create(FindCriteria.class);
            List l = new ArrayList();
            fc.setExcludeAttribute(true);
            l.add("PurchaseOrderLine");
            fc.setFindAttribute(l);
            PurchaseOrderResult res = svc.findPurchaseOrder(fc, null);
     
            // Retrieve only the 2nd Emp along with Dept with Deptno=10.
            FindCriteria fc = (FindCriteria)DataFactory.INSTANCE.create(FindCriteria.class);
            // Create the view criteria item.
            List value = new ArrayList();
            value.add(new Integer(10));
            ViewCriteriaItem vci =             (ViewCriteriaItem)DataFactory.INSTANCE.create(ViewCriteriaItem.class);
            vci.setValue(value);
            vci.setAttribute("Deptno");
            List<ViewCriteriaItem> items = new ArrayList(1);
            items.add(vci);
            // Create view criteria row.
            ViewCriteriaRow vcr = (ViewCriteriaRow) DataFactory.INSTANCE.create(ViewCriteriaRow.class);
            vcr.setItem(items);
            // Create the view criteria.
            List group = new ArrayList();
            group.add(vcr);
            ViewCriteria vc = (ViewCriteria)DataFactory.INSTANCE.create(ViewCriteria.class);
            vc.setGroup(group);
            // Set filter.
            fc.setFilter(vc);
     
            List cfcl = new ArrayList();
            ChildFindCriteria cfc =           
              (ChildFindCriteria)DataFactory.INSTANCE.create(ChildFindCriteria.class);
            cfc.setChildAttrName("Emp");
            cfc.setFetchStart(1);
            cfc.setFetchSize(1);
            cfcl.add(cfc);
            fc.setChildFindCriteria(cfcl);
            DeptResult dres = svc.findDept(fc, null);
            pw.println("### Dept 10 and 2nd Emp ###");
    

42.5 Securing the Design Pattern

For more information about securing the use case, see Chapter 51, "Securing Web Services Use Cases."

42.6 Verifying the Deployment

To properly verify this design pattern, test your ADF Business Components object in an application module tester or a UI.

To verify this design pattern:

Test your Oracle ADF application using the various testing and debugging methods described in the chapter "Testing and Debugging ADF Components" in Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.