Let's say that you have a presentation tier in JSF, and that your business tier is accessed using web services. How would you call your web services from JSF?
I was considering to have my backing beans to call the web services, but I just though I could use Ajax with JSF in order to connect to the web services. What would you choose and why? Any other choice you could recommend?
EDIT: I'm using Spring in the business tier, maybe that info may help with the suggestions.
Thanks.
I'd wrap the web service call in a service class, that is accessed via the managed bean. Thus the front-end will not know how exactly the data comes to it - via web services, or via any other means.
Let's say that you have a presentation tier in JSF, and that your business tier is accessed using web services. How would you call your web services from JSF?
The "classic" approach would be to inject a JAX-WS proxy factory class (generated from the WSDL) in a ManagedBean:
public class ItemController {
@WebServiceRef(wsdlLocation = "http://localhost:8080/CatalogService/Catalog?wsdl")
private CatalogService service;
public DataModel getItems() {
if (model==null || index != firstItem){
model=getNextItems();
}
return this.model;
}
public DataModel getNextItems() {
Catalog port = service.getCatalogPort();
model = new ListDataModel(port.getItems( firstItem,batchSize));
return model;
}
}
Sample taken from Sample Application using JAX-WS, JSF, EJB 3.0, and Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With