Friday Apr 20, 2012

Which option to choose for accessing Web Services in ADF

Oracle ADF provides three options for integrating Web Service:

· Web Service Data Control

· JAX-WS proxy client and POJO Data Control

· JAX-WS proxy client and programmatic View Objects

Note: In the above, I exclude REST services in my recommendation because this is what ADF will address much better using the URL data control in JDeveloper 11g R2 (available) and with improved functionality in the upcoming Oracle JDeveloper 12c release.

For deciding which option to use for integrating Web Service, here is what I consider "a good rule of thumb"

1. Use Web Service Data Control only for simple service like weather reports or stock quotes

2. Use JAX-WS proxy client for all more complex services and access them from

a. Programmatic view object and entity if your business service is ADF Business Components as this allows for better integration with database queried  views

i. Use View Objects only for read only access

ii. Use View Objects and Entities for CRUD Web Service integration

b. POJO Data Control

i. If your business service is not ADF BC.

ii. If the WS doesn't require integration in ADF business component

iii. If WS access should be from a bounded task flow in an ADF library for maximum reuse

As a general hint of best practice: Never use the JAX-WS generated proxy client directly. Always access it from a wrapper bean to avoid code losses or problem in cases where the proxy client needs to be re-generated.

Note: ADF Code Corner published an article explaining how to cache Web Services results when using JAX-WS proxy clients to avoid unnecessary round trips. See: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/92-cache-ws-queries-523136.pdf


        
    

Tuesday Feb 28, 2012

Best practice invoking business services methods from JSF beans

Recently there was an increasing interest on OTN in best practices for invoking methods exposed on the ADF Business Components client interface. There exist two options to access methods exposed on ADF Business Components application modules and view objects from a managed bean through ADF.

  • Call findDataControl(String) on the BindingContext and access the application module to invoke a method exposed on the Application Module or View Object client interface.

  • Create a method binding on a PageDef level that binds to a method exposed on the Application Module or View Object client interface

Speaking of best practices, it’s the second option  to use a method binding on the PageDef file that I recommend for the following reasons

  • ADF is about abstracting the view and controller layer from the business service implementation details. A method binding instead exposes an ID (the name o the binding) to the JSF developer, which they use to access the binding from a managed bean using the OperationBinding API. Signature or name changes of a method exposed on the business service thus don't require a change in the managed bean(s) referencing it. All changes would be applied in metadata.

  • ADF provides the OperationBinding class as an abstraction for business services methods. Configuring business service method access on the PageDef file using method bindings exposes a single and consistent API to application developers.

  • Programmatic access to a method exposed on the business service require more lines of code than accessing the same method through the binding layer

  • Direct business service access violates the recommendation to always work through the ADF binding layer and not to bypass it.

To access a method binding from a managed bean, use the following code

  BindingContext bctx = BindingContext.getCurrent();
  BindingContainer bindings = bctx.getCurrentBindingsEntry();
  OperationBinding operationBinding = 
       bindings.getOperationBinding("name_of_method_binding");
  //optional
  operationBinding.getParamsMap().put("argumentName1",value1);
  operationBinding.getParamsMap().put("argumentName2",value2);
  //invoke method
  operationBinding.execute();
  if (!operationBinding.getErrors().isEmpty()) {
     //check errors
     List errors = operationBinding.getErrors();
     ...
  }
  //optional
  Object methodReturnValue = operationBinding.getResult();


About

A blog on Oracle JDeveloper, ADF, MAF, MCS and other mobile and web topics inspired by questions and answers posted on the OTN forums.



Frank Nimphius

Search

Archives
« April 2015
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
       
Today