Web Services with Complex Data Types in ADF 11g

A guest post by Srikant Subramaniam from our Fusion Middleware for Apps product management group.

The Web Service Data Control

The Web Service Data Control in ADF 11g provides an easy and convenient interface to incorporate web services in an ADF application. The data control abstracts the implementation of a business service (such as a web service) thus providing a consistent mechanism for the ADF pages to access the data.

While most of the simple samples out there will show you how to invoke a Web service that returns a simple string, there are some specific things you need to know when you are working with complex data types.

Complex Data Types

A complex data type wraps a number of attributes, such as an array of objects. For instance, the request object for the "getObject" operation contains an array of individual attributes as shown below:

snap001.jpg

Similarly, the response object can also contain several individual attributes:

snap-0107.gif

In JDeveloper 10.1.3 there was no out-of-the-box support for complex data types, hence the inability to drag and drop only the relevant input/output attributes onto the JSF page when designing the ADF UI.
As a result, we had the following workarounds:
1. For complex input parameters, create an instance of the complex input type in a managed bean and add it to the parameter map of an Oracle ADF operation binding that invoked the web service, as described here.
2. For complex return types, either via the use of web service data control; or a web service proxy, as described here.
While these workarounds were fully functional, they introduced the need for custom Java coding/development.

This has changed with JDeveloper and ADF 11g, and complex data types are now supported out-of-the-box, creating an ADF client does not require any custom Java coding and is accomplished via drag/drop style data binding of the complex data types.

This tutorial shows how to build an ADF 11g client using complex data types.

[update June 2010] Frank has a good sample about complex type parameters and how you can leverage ADF binding to set properties of them here: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/54-ws-complex-input-type-169197.pdf

Another example that might be useful here - http://blogs.oracle.com/shay/2010/05/updateinsert_with_adf_web_serv.html

Comments:

I have a problem. When I drag return attribute to the page then web service is called on page load.

Posted by Andreja on September 16, 2009 at 09:13 PM PDT #

Andreja, You'll need to check the refresh condition assign to the WS execution in the page binding. This solution might help: http://blogs.oracle.com/shay/2009/01/preventing_queries_when_page_f.html

Posted by shay on September 17, 2009 at 09:40 AM PDT #

Hi Shay, from an architecture point of view I would never use the WS-DataCorntol directly. I suggest to use a WS-ClientProxy generator like CXF, AXIS, Oracle, ... and use the POJO-Datacontroll. If you connect the DC directly against WS you can't use all WS-standards like, SAML with Kerberos, WS-Adressing, WS-Reliability etc. Furthermore, in a more complex szenario we found a lot of pitfalls where we was unable to solve with the current WS-DC implementation. - che

Posted by anyone on October 19, 2009 at 06:18 AM PDT #

Che, I agree that using the Java client proxy generation capability in JDeveloper to create a Java class that invokes the Web service, and then expose that class as a data control is potentially a more powerful and flexible combination. But sometime the quick and dirty way that the Web service data control offers is a good enough solution. Shay

Posted by shay on October 19, 2009 at 06:22 AM PDT #

Hi Shay, I was googling for a long time for this information. This is one is great. It gave me exactly what I was looking for. Thanks so much.

Posted by anonymous on December 17, 2009 at 03:50 AM PST #

The link in the following statement is taking somewhere else. Could please check? This tutorial shows how to build an ADF 11g client using complex data types.

Posted by Kamleshwar on January 20, 2011 at 04:32 AM PST #

Thanks for the note - I updated the link - and added a couple of others at the end with a bit of more samples.

Posted by shay.shmeltzer on January 21, 2011 at 08:44 AM PST #

It's a much usefull link..thanks shay..

Posted by guest on June 12, 2011 at 06:10 PM PDT #

I created a JSF page from a WS data control and successfully posting the request and got the result back.But the content is not displaying on the JSF page. i used output read only form to display the result. please suggest.

Posted by guest on June 12, 2011 at 07:24 PM PDT #

guest, It is hard to say what you have done wrong without more details - I would suggest that you post your question on the JDeveloper forum on OTN with a bit more details. You can use the HTTP Analyzer in JDeveloper and debugger to see the messages to your web service and the values in your binding layer.

Posted by Shay on June 13, 2011 at 07:24 AM PDT #

Hi Shay,
I'm new to ADF and loving your video tutorials.
In my case, I am using a street address search web service which takes 3 input params (2 of which I'd like to hard code and not provide text input boxes for) and which returns an array of objects - each object containing an array of strings comprising a single street address (i.e. street number, street name, suburb, zip code). I would like to format each string array as a comma separated string in a list box so that the user may select one single address. Is this even possible with just ADF drag-and-drop features? I'm not having much luck so far. Is it more complex and requires additional logic?
Many thanks,
Darren

Posted by Darren on August 25, 2011 at 02:20 AM PDT #

Darren,
My guess is that you'll be better of using a Java class proxy that invokes your web service, and then formats the returned object to the way you want to show it on the screen.
Then you can expose this proxy class as an ADF Data control - and drag the method and formatted result into the page.

Posted by Shay on August 25, 2011 at 06:28 AM PDT #

Thanks Shay. Do you have any tutorials that show how to expose a proxy class as an ADF control in jDeveloper?

Thanks again,
Darren

Posted by guest on August 25, 2011 at 11:40 PM PDT #

Hi Shay,This is very helpful.I have a question.If the webservice taking inputs as both object and string i.e. if it takes two params,can i drag and drop the second parameter in the form(object dragged as form),how can i do that...If you have any resources helpful for dealing with webservice datacontrols in detail..Could you please share ....

Posted by guest on September 14, 2013 at 10:12 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

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