Services Tab Web Services Public Contracts

Modificaion 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



When the user drag and drops a Web Service or Web Service method on to one of Web Service the consumer (Ex. VWP designer or JSP editor), it must know the contents of DnD transferable. Similarly, after receiving the DnD, the consumer must use some API to talk to the Service manager to obtained additional meta data about the Service stored locally; for example to obtained the Web Service proxy information created while adding the Web Service to the root node. So Web Service Manager, which manager the nodes must publish some public contracts (API's) to aid the consumer like

  • A Contract between the consumer and the Nodes in the Services tab from which DnD gets initiated.
  • A Contract between the consumer and the Web Services Manager to get meta data information about the dropped Web Service.

Web Service Meta-data descriptor

The meta data descriptor describes about the W/S added to the respository. For example, the Metadata descriptor for GoogleSearch W/S would contains the following information

<?xml version="1.0" encoding="UTF-8"?>
<ServiceType name="WebService">
   <WebService name="GoogleSearch" displayName="GoogleSearch">
      <Jar name="GoogleSearch.jar" type="proxy-ja">
      <Jar name="GoogleSearch_dt.jar" type="designtime"/>

Web Service manager and consumer add help contract

When the Web Service is added to repository via the Web Services, a proxy client of the Web Service is created and stored in the Meta Data repository of the added Web Services.

Also, In order to minimize the time between the drop of DnD and the corresponding binding to appear in the designer, the VWP W/S consumer to generate additional jars, like designtime jars, when the W/S is add. These may not be required by other W/S Consumer module. Since the W/S Manager does not know how to create these consumer specific meta-data, the solution may be to provide an option for the Consumer modules to participate in the service adding process. This could be achieved by the W/S Manager publishing some public contract

Assume, W/S manager published a interface API called WsServiceManagerExtension, which can be implemented by the consumers and then register it as service via Java Extension mechanism. Then W/S Service manager can look up this extended service and call the implemented method to allow the consumer to create additional meta-data required.


Interface WsServiceManagerExtension{
  public boolean wsServiceAddedExtension(File wsMetadataDesc);
  public boolean wsServiceRemovedExtension(File wsMetadataDesc);

The Consumer Module like VWP W/S service consumer would implement the extension as

public final class VwpWsServiceManagerExtensionImpl implements WsServiceManagerExtension{
    public boolean wsServiceAddedExtension(File wsMetadataDesc){
         // Get the proxy jar as define in the metadata descriptor
         // Create the wrapper class and add it to the proxy jar 
         // Create the design time jar add to location wsMetadataDesc.getParentFile()
         return true; // false if creation failed

Now, the additional step taken by Web Serice Manager while adding the service is

public final class  WsServiceManager{
   public boolean addWebService(WsService ws){
       // Add the W/S to repository location 
       // Call the W/S add extensions
       WsServiceManagerExtension[] wsmExts = Lookup.lookup("WsServiceManagerExtension");
       for (for int i = 0; I < wsExs.lenght; i++){

Adding the wrapper class and design time

When the Web Service is added to the designer, an instance of the proxy client will be added to the page being designed. One of the requirement is that the proxy must be a Java Bean (only default constructor). Since the proxy could be a non Java Bean, a wrapper class is created and injected in to the proxy jar, when the wsServiceAddedExtension is called.

Drag and Drop Contract

The contract that explains the contents of the DnD Transferable (Data Flavors & transfer data etc). The Web Service manager Module must publish the contract explaining the contents of the Transferable, Data Flavors etc. This information is used by the Service Helper (or by the Service Client as explained above). Here is an example of DnD Contract that could be published by Web Service manager module. The WsInfo class is sent as Transfer data

public final class WebServiceMetaDataTransfer 
  // For W/S drag and drop
  public static DataFlavor WS_FLAVOR;
  public static final class WsInfo{
     private final WebServiceDescriptor wsDescriptor;
  // For W/S method drag and drop
  public static DataFlavor WS_METHOD_FLAVOR;
  public static final class WsMethodInfo{
     private final WebServiceMethodDescriptor wsMethodDescriptor;

The Web Service Consumer can now obtain the WsInfo from the DataFlavor as follows.

    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 needed

The WebServiceDescriptor is one of the Service Meta-data Contract APIs published by the Web Service Manager, for the consumer to interact as explained below.

Service Meta data Contract

The Web Service manager keeps information about the W/S displayed in the W/S root node. So in order for consumer to get these information it must publish set of API. For example, after the consumer gets the WebServiceInfo from the DnD transferable, it needs to get the additional Metadata information. So the Webservice manager module would publish the following public API, whose implementation could be reached via the DnD contract as explained above

public interface WebServiceDescriptor {
     public WSDL getWSDL(); 
     public File getProxyJar(); 
     public File getDescriptor(); 
     public String getDisplayName();

The Service Consumer would either get the proxy Jar and add it to the project or get the WSDL and creates its own proxy and then inject the relevant source to the JSP Editor. Once, the Web Service information is obtained from the transferable it is up to the consumer to consume the service.

For example, VWP designer might create a dataprovider using the wrapper class it added to the proxy jar and then binds it to a component in the page.

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