views:

23

answers:

1

I have a Web Service operation called getJobCostToDate(String jobnum) which when passed a job number it will return the job cost to date.

The page I am displaying shows job data in a row, and the job cost to date is one column of the table data.

I have discovered that I should be able to call the web service operation using a managed bean in the back end but I don't know enough about JSF or writing web service proxy clients to work out how I should be doing this.

I'd like to be able to call an operation in the backend bean and pass the job number of the row to get the cost to display, but I've read that JSF doesn't work like that.

I've looked at some JSF books in the bookstore and they don't have any good examples of how to call web service operations using JSF beans. I've also had difficulty finding anything good articles or examples searching in google.

Can anyone recommend any good books or articles that cover this? Or can anyone point me in the right direction?

Any help would be much appreciated!

A: 

Some vendors have JSF tooling that will generate beans from WSDL, in effect it feels like you just drag that WSDL to the page. I work with IBM Eclipse-based products which have this capability, but it's possible that the free Eclipse tooling may have what you need.

In the very worst case it should not be hard to roll this yourself:

1). Generate a Java client from WSDL, Eclipse should deal with that.

2). If that generated code is a Bean then fine, you now have something to use with JSF. If not, then write a simple Java Bean

public class MyServiceBean {

      private ServiceClient myServiceCaller;
      /* plus variables to hold service result */

      public MyServiceBean() { /* init code */ }

      private invokeService() { /* invoke service, save result */ }

      public getSomeValue() {
            invokeService();
            /* return value */
      }
      /* other getters */
}

Now you have bean that can be used lust like any other. Equally you can invoke the service in the Backing Bean - I see no reason object to doing service invocation there.

djna