Coding Parameter Values for Web Services Binding

I got a request for help from a partner yesterday, they were looking for a way to assign values to a list of parameters of a web service in a managed bean.

Since the day before that I answered a very similar question that also asked about the process to access the value of object on the screen through the binding layer, I figured out I might as well put the steps in a blog entry. I'm sure at one point in the future I'll probably need this again - this way it will be easily accessible.

With ADF binding it is very simple to create a JSF page that will let you insert a set of parameters in input items and then invoke a Web service passing these parameters.
All you need to do is create a Web Service Data Control based on the WSDL and then drag it onto your JSF page as an "ADF Parameter Form".
Now you have an inputText field for each parameter of the WS and a submit button that will invoke the WS.

Now if you want to fill out values for the parameters programatically do the following:

Go to the JSF source and remove the inputItems from there - Note that doing it this way will keep the binding for them in the pagedef.xml file.

Double click the submit button to create the method for it in a backing bean.

In that method you can use something like the following:


FacesContext fc = FacesContext.getCurrentInstance();
ValueBinding expr=fc.getApplication().createValueBinding("#{bindings.param.inputValue}");
expr.setValue(fc, "joe");

(In your case replace the param with the name of the binding for your specific parameter - you can find the name in the pagedef.xml file).

That's it.

Note that in cases where you want to get the value of a binding item you can replace expr.setValue with expr.getValue.

More about this in chapter 17.5 of the ADF Developer Guide.

Note - update for 11g is here.

Comments:

Hello, sorry for asking questions not exeactly related to the post (as much as I understand:), but I could not get help from anywhere else for weeks, and I hope you can help me with the following. I have two web services: one for reading and another for writing the database. I need to create a JSF page with a form, where the default values of the input fields come from the reader web service, and on submit the writer web service is called. (Writing works, but I can't manage to set the default values.) (A little more detailed description: http://forums.oracle.com/forums/thread.jspa?messageID=1692696#1692696) Your help would be much appreciated. Thanks, Patrik

Posted by Patrik on July 18, 2007 at 12:10 AM PDT #

I guess coding like I did in this sample can work. But in the case you describe you just need to manipulate the value of the input parameter to the WS in the pagedef.xml so it will get its value from another binding. (I replied on the thread with a sample).

Posted by Shay Shmeltzer on July 18, 2007 at 11:11 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