Visual Web Consumer of Web Services from Services Tab

Modification History
Winston Prakash: Feb, 8 2007

Note: This is just sample or a starter document to start the discussion based on Services Tab Architecture. Does not correctly reflect the implementation details. Need to be re-written by the Service Type implementor. - Winston

This document applies only to VWP designer - Winston



This document explains how the Visual Web Pack Service Consumer would consume a Web Service (or a Web Service Method) once it is Drag and Dropped from a Web Services Node in the Sevices Tab. VWP web page designer (here after just designer) is the primary receiving agent of the Drag and Drop. It could consume it directly or delegate the task to a Helper.

Web Service Consumer

VWP web page designer could extract the Web Service info from the DnD using the public Contract defined in the Web Service Public Contracts document. Instead it delegates the actual consumption task to a helper module. For Web Service consumption the task is delegated to the ravewebsvc module, which we would refer as Web Service Consumer Helper.

Let us see an example on how the designer would consume the Web Service Table dropped on to it. The only consumable object designer understands is BeanCreateInfoSet (a generic definition of consumable object holder defined by the VWP Design Time System). The designer could implement the required code to convert the DnD to an BeanCreateInfoSet. That means designer needs to understand the DnD contract defined by Web Service Manager.

However, the preferred solution would be to use the Consumer Helper and pass on the DnD Transferable to it. The Consumer Helper would take the DnD and creates the BeanCreateInfoSet and gives it back to the designer. The advantage of this approach is, designer need not have to know about the DnD Contract nor the Service Meta data Contract to convert the DnD Transferable to a consumable object, but relies on the Consumer Helper to do the job.

Web Service Consumer Helper

Since there can be multiple Consumer Helper modules to help consume DnD from Nodes of different Services in the Services Tab, designer need to interact with each of these Helpers, thus creating module dependencies. Since VWP Design Time System defines a single wrapper consumable object, designer could provide a public SPI for these helpers and then relies on NB lookup mechanism to get the implementors of this SPI. Out of the several possible Helpers, only one will understand the DnD transferable corresponding to Web Service. One such Helper would be implemented in the ravewebsvc module

Here is an Example interface that could be defined by the VWP designer

public interface DesignTimeTransferDataCreator {
    /** Gets <code>DisplayItem</code> for specified <code>Transferable</code>
     * @return <code>DisplayItem</code> or <code>null</code> */
    public DisplayItem getDisplayItem(Transferable transferable);

Note: DisplayItem is a super interface of BeanCreateInfoSet.

The ravewebsvc Module can implement the VWP specific Service Helper and register it

  public final class WebServiceTransferDataCreator implements DesignTimeTransferDataCreator{
     public DisplayItem getDisplayItem(Transferable transferable){
       // Use the DnD contract to get the info about service
       // If the transferable is not understood (may not be a W/S service DnD)
       // return null
       // Use the Service Meta data contract to get ServiceProxy
       DataFlavor supportedFlavor = WebServiceMetaDataTransfer.WS_FLAVOR;
       if (transferable.isDataFlavorSupported(supportedFlavor)){
            transferData = transferable.getTransferData(supportedFlavor);
            WebServiceMetaDataTransfer.WebServiceInfo wsInfo =  
                (WebServiceMetaDataTransfer.WebServiceInfo) transferData;
            // Obtain the Web Service descriptor  
            WebServiceDescriptor wsDesc = 
            // Now use WebServiceDescriptor as create the BeanCreateInfoSet
            return new return new WebServiceBeanCreateInfoSet(wsDesc);

Note that, this Consumer Helper get the Web Service information via the Web Service Metadata Contract published by the Web Service manager.

Adding Web Service to project

An Web Service can be added to a page bean, a session bean or an application bean by drag and drop the W/S or W/S method on to the designer or corresponding scoped bean in the application outline. When the very first Web Service from a set is dropped into a web project, all the client jars and the wrapper jar in this Web Service set will be added into the project navigator. But removing all the Web Services from the project will not cause the jars to be removed from the project automatically. The user can remove the jar manually from the project navigator if he or she wants.

When an Web Service is dropped in the web application, an instance of the Web Service wrapper class is created in the backing bean.

Access Web Services in backing beans

The web application uses the bean wrapper class to access the Web Service's business methods.

  • For read-only data, the user can use the binding dialogs provided by the components to bind appropriate data providers to the JSF components.
  • For updating/deleting data, the user has to manually make calls to the business methods in the backing beans. Of course, the user can still manually call the business methods to retrieve data if that's what he or she wishes.

Binding W/S methods to components

Other than dragging and dropping an Web Service into a web application, the user can also drag and drop methods which have read-only data providers associated it. We'll call those methods bindable methods since they can potentially be bind to JSF components. When the user drops the method on the designer canvas, an instance of the wrapper class and data provider for the method will be created in the backing bean. Just like dropping Web Services to the web application, the methods can also be dropped in different scope (i.e. Request, session and application). If the user drops the method onto a JSF component, then VWP will try to bind the data provider instance for the method to the JSF component.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo