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:
ADF Business Components service
A local ADF Business Components object (such as an application module or an entity object), or from a UI via either a local ADF Business Components object or a managed JavaBean
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.
One alternative is to use JAX-WS to generate static proxy classes. This is prohibited for ADF Business Components services because:
Using JAX-WS generates many proxy classes that you need to maintain, which increases maintenance costs.
oracle.jbo.client.svc.ServiceFactory
uses a local Java call if the service is co-located, which offers performance benefits.
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 Working with Data from a Remote ADF Business Components Service.
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.
To invoke an ADF Business Components service from an Oracle ADF application:
Example 43-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>
Example 43-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);
Example 43-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 ###");
Related Links
The following documents provide additional information related to subjects discussed in this section:
For more information about invoking ADF business components services from an Oracle ADF application, see the chapter "Integrating Service-Enabled Application Modules" in Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about integrating service-enabled application modules, see the chapter "Integrating Service-Enabled Application Modules" in Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about securing the use case, see Securing Web Services Use Cases .
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.
Related Links
Fore more information about testing Oracle ADF applications, see the chapter "Testing and Debugging ADF Components" in the Developing Fusion Web Applications with Oracle Application Development Framework.