Skip to main content

skip to main content

developerWorks  >  SOA and Web services  >

Service Registry Proxy

A higher-level API

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

Alfredo Silva (afdasilv@us.ibm.com), Advisory Software Engineer, IBM

01 Nov 2001

In order to provide additional tools to the Web services developer, this article discusses a new API -- the Service Registry Proxy, or SRP -- which helps to raise the abstraction level during application development and promotes seamless integration between UDDI and WSDL elements.

The release of the UDDI4J API (see Resources for links to this and other references made in this article) enabled the creation of UDDI-aware applications, making the publish, unpublish and find operations available from an open-source API.

In order to allow WSDL documents (see Resources for a link) to be part of this equation, a new layer called the Service Registry Proxy API (or SRP), which sits on top of the UDDI4J, has been devised.

The SRP API elements encapsulate classes present in the UDDI4J API, and some defined by the WSDL4J API, and offer a comprehensive set of methods for interfacing with a UDDI Registry. Its model simplifies the development of applications because it raises the level of abstraction, enabling the developer to concentrate on entities directly related to the Web services architecture domain.

SRP supporting classes

The SRP API is structured around the following main elements: Service Provider (SP), Service Definition (SD), Service Implementation (SIMP), and Service Interface (SITF), as shown in Figure 1.


Figure 1: SRP API main elements
Figure 1: SRP API main elements

  • SP
    The Service Provider represents an entity capable of providing services. It encapsulates a reference to the UDDI4J class BusinessEntity.
  • SD
    The Service Definition describes a service by breaking it down into two pieces: implementation (SIMP) and a list of the implemented interfaces (SITF).
  • SIMP
    The Service Implementation has a dual role. It exposes the related WSDL implementation document (see Resources) and also has a reference to the UDDI4J class BusinessService.
  • SINT
    The Service Interface also encapsulates two entities: a WSDL interface document (see Resources) and a reference to the UDDI4J class TModel.

The WSDL capabilities presented by SIMP and SINT are inherited from their parent class WSDLServiceInfo.

This organization enables SRP to tie together UDDI and WSDL elements and, at the same time, abstract their concepts -- thereby making the creation of Web services a more productive task.



Back to top


SRP data structure

Internally, SRP has the main attributes you see illustrated in Table 1. They handle the interface with the UDDI4J API and maintain relevant UDDI Registry connection information.


Table 1: SRP attributes

Attribute Description
protected int maxRowsReturned = 100; Max number of rows returned
protected int numRowsToSearch = 100; Max number of rows to search
protected String inquiryURL; URL used in Find operations
protected String publishURL; URL used in Publish operations
protected String userId; Userid to connect to the UDDI Registry
protected String cred; Password to connect to the UDDI Registry
protected UDDIProxy uddiProxy; UDDI4J proxy object



Back to top


API functionality

The SRP API consists of the following functional groups: Publish, Unpublish, and Find -- as shown in Table 2. For complete SRP API javadocs, please see Resources for a link.


Table 2: SRP functional groups

API Sub-API Method Call Description
Publish     Publishes ServiceProviders, ServiceDefinition, and ServiceInterface objects
       
    publish (ServiceProvider) : ServiceProvider  
    publish (ServiceProvider, ServiceDefinition) : ServiceDefinition  
    publish (ServiceInterface) : ServiceInterface  
       
Unpublish     Unpublishes ServiceProviders, ServiceDefinition, and ServiceInterface objects
       
    unpublish (ServiceProvider) : void  
    unpublish (ServiceInterface) : void  
    unpublish (ServiceProvider, ServiceDefinition) : void  
       
Find      
  Service Provider   Find ServiceProvider objects given a search criteria
       
    findAllServiceProviders (FindQualifiers, boolean) : ServiceProvider[]  
    findServiceProvider (ServiceDefinition) : ServiceProvider  
    findServiceProvider (String) : ServiceProvider  
    findServiceProviders (FindQualifiers, DiscoveryURLs) : ServiceProvider[]  
    findServiceProviders (FindQualifiers, TModelBag) : ServiceProvider[]  
    findServiceProviders (String, boolean) : ServiceProvider[]  
    findServiceProviders (CategoryList) : ServiceProvider[] 
    findServiceProviders (IdentifierList) : ServiceProvider[]  
       
  Service Definition   Find ServiceDefinition objects given a search criteria
       
    findAllServices (FindQualifiers, boolean) : ServiceDefinition[]  
    findService (String) : ServiceDefinition 
    findService (FindQualifiers, ServiceProvider, ServiceImplementation) : ServiceDefinition 
    findServices (FindQualifiers, TModelBag) : ServiceDefinition[]  
    findServices (String, boolean) : ServiceDefinition[]  
    findServices (FindQualifiers, ServiceInterface) : ServiceDefinition[]  
    findServices (ServiceInterface, String) : ServiceDefinition[]  
    findServices (ServiceInterface, CategoryList) : ServiceDefinition[]  
    findServices (ServiceProvider, String) : ServiceDefinition[]  
    findServices (FindQualifiers, ServiceProvider) : ServiceDefinition[]  
    findServices (FindQualifiers, ServiceProvider, CategoryList) : ServiceDefinition[]  
    findServices (FindQualifiers, CategoryList) : ServiceDefinition[]  
    findServices (ServiceList) : ServiceDefinition[]  
       
  Service Interface   Find ServiceInterface objects given a search criteria
       
    findAllServiceInterfaces (FindQualifiers, boolean) : ServiceInterface[]  
    findServiceInterface (String) : ServiceInterface  
    findServiceInterfaces (String, boolean) : ServiceInterface[]  
    findServiceInterfaces (FindQualifiers, IdentifierList) : ServiceInterface[]  
    findServiceInterfaces (FindQualifiers, CategoryList) : ServiceInterface[]  
    findServiceInterfaces (ServiceImplementation) : ServiceInterface[]  
    findServiceInterfaces (ServiceImplementation, String) : ServiceInterface[]  
    findServiceInterfaces (ServiceImplementation, IdentifierList) : ServiceInterface[]  
    findServiceInterfaces (ServiceImplementation, CategoryList) : ServiceInterface[]  



Back to top


Putting it to work

The demos in this article illustrate the capabilities of the SRP API by publishing, finding, and finally unpublishing a Service Provider element. The source code is shown in Listings 1, 2, and 3. Please feel free to use and adapt this code for your own projects.

The ServiceProviderPublishDemo, during its initialization phase, creates an SRP object with specific URLs to publish and inquire as well as a userid and password which have been pre-registered with the target UDDI registry. A CategoryList class is instantiated to support the creation of a ServiceProvider that also needs a name and a description.

Once the ServiceProvider is successfully created, the SRP publish method is invoked -- receiving this object as its only parameter. The code checks for possible error conditions issuing appropriate messages during its execution.


Listing 1: Service provider publish demo


     import com.ibm.wstk.service.provider.*;
     import com.ibm.wstk.service.registry.*;
     import com.ibm.wstk.service.util.*;
     import com.ibm.wstk.uddi.*;


     public class ServiceProviderPublishDemo
     {
       public static String UDDI_TEST_REGISTRY_INQUIRY
     = "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi";
       public static String UDDI_TEST_REGISTRY_PUBLISH
     = "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi";
       public static String UDDI_USER = "srpuser";
       public static String UDDI_PASSWD = "srppwd";
       public static String SERVICE_PROVIDER_NAME = "demo provider";
       public static String SERVICE_PROVIDER_DESC = "SRP provider demo";
       public static String TMODEL_KEY = "NAICS";
       public static String KEY_NAME = "Greeting Card Publishers";
       public static String KEY_VALUE = "511191";


       public static void main(String args[])
       {
         try
         {
           //////////////////// INITIALIZATION
     /////////////////////////////////

           // Create Service Registry Proxy
           ServiceRegistryProxy srp =
             new ServiceRegistryProxy(UDDI_TEST_REGISTRY_INQUIRY,
                                      UDDI_TEST_REGISTRY_PUBLISH,
                                      UDDI_USER, UDDI_PASSWD);

           // Create category list
           CategoryList categoryList =
             new CategoryList(TModelKeyTable.getTModelKey(TMODEL_KEY),
                              KEY_NAME, KEY_VALUE);

           // Create service provider
           ServiceProvider serviceProvider =
             new ServiceProvider(SERVICE_PROVIDER_NAME,
                                 SERVICE_PROVIDER_DESC,
                                 categoryList);

           //////////////////// PUBLISH
     ////////////////////////////////////////

           // Publish the service provider
           srp.publish(serviceProvider);

           // Display publish completed message
           System.out.println("Service provider " + "\"" +
                              SERVICE_PROVIDER_NAME + "\"" + " was published.");
         }
         catch (ServiceRegistryProxyException e)
         {
           System.out.println("ServiceRegistryProxyException: " + e.getMessage());
         }
         catch (InvalidCategoryException e)
         {
           System.out.println("InvalidCategoryException: " + e.getMessage());
         }
       }
     }



The demo responsible for finding a ServiceProvider creates an SRP instance with the same parameters used by the previous demo.

The previously published ServiceProvider is then found using one of the find SRP methods, and appropriate messages are generated during execution:


Listing 2: Service provider find demo


     import com.ibm.wstk.service.provider.*;
     import com.ibm.wstk.service.registry.*;
     import com.ibm.wstk.service.util.*;
     import com.ibm.wstk.uddi.*;


     public class ServiceProviderFindDemo
     {
       public static String UDDI_TEST_REGISTRY_INQUIRY
     = "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi";
       public static String UDDI_TEST_REGISTRY_PUBLISH
     = "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi";
       public static String UDDI_USER = "srpuser";
       public static String UDDI_PASSWD = "srppwd";
       public static String SERVICE_PROVIDER_NAME = "demo provider";


       public static void main(String args[])
       {
         try
         {
           //////////////////// INITIALIZATION
     /////////////////////////////////

           // Create Service Registry Proxy
           ServiceRegistryProxy srp =
             new ServiceRegistryProxy(UDDI_TEST_REGISTRY_INQUIRY,
                                      UDDI_TEST_REGISTRY_PUBLISH,
                                      UDDI_USER, UDDI_PASSWD);

           //////////////////// FIND
     ///////////////////////////////////////////

           // Find the published service provider
           ServiceProvider[] serviceProviderList =
             srp.findServiceProviders(SERVICE_PROVIDER_NAME, true);

           // Display find completed message
           if (serviceProviderList == null)
             System.out.println("Service provider " + "\"" +
     SERVICE_PROVIDER_NAME
                                + "\"" + " was not found.");
           else
           {
             System.out.println("Service Provider Name: " +
                                  serviceProviderList[0].getBusinessEntity
     ().getNameString());
             System.out.println("          Description: " +
                                serviceProviderList[0].getBusinessEntity
     ().getDefaultDescriptionString());
           }
         }
         catch (ServiceRegistryProxyException e)
         {
           System.out.println("ServiceRegistryProxyException: " + e.getMessage());
         }
       }
     }



At last it is unpublish time. Initialization is the same as before. Then the target ServiceProvider is found and unpublished via the appropriate SRP unpublish method. Again, errors are monitored and reported.


Listing 3: Service provider unpublish demo



     import com.ibm.wstk.service.provider.*;
     import com.ibm.wstk.service.registry.*;
     import com.ibm.wstk.service.util.*;
     import com.ibm.wstk.uddi.*;


     public class ServiceProviderUnpublishDemo
     {
       public static String UDDI_TEST_REGISTRY_INQUIRY
     = "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi";
       public static String UDDI_TEST_REGISTRY_PUBLISH
     = "https://www-3.ibm.com/services/uddi/testregistry/protect/publishapi";
       public static String UDDI_USER = "srpuser";
       public static String UDDI_PASSWD = "srppwd";
       public static String SERVICE_PROVIDER_NAME = "demo provider";


       public static void main(String args[])
       {
         try
         {
           //////////////////// INITIALIZATION
     /////////////////////////////////

           // Create Service Registry Proxy
           ServiceRegistryProxy srp =
             new ServiceRegistryProxy(UDDI_TEST_REGISTRY_INQUIRY,
                                      UDDI_TEST_REGISTRY_PUBLISH,
                                      UDDI_USER, UDDI_PASSWD);

           //////////////////// UNPUBLISH
     //////////////////////////////////////

           // Find the published service provider
           ServiceProvider[] serviceProviderList =
             srp.findServiceProviders(SERVICE_PROVIDER_NAME, true);

           if (serviceProviderList != null)
           {
             // Unpublish the service provider
             srp.unpublish(serviceProviderList[0]);

             // Display unpublish completed message
             System.out.println("Service provider " + "\"" +
                                SERVICE_PROVIDER_NAME + "\"" + " was unpublished.");
           }
           else
             // Display error message
             System.out.println("Service provider " + "\"" +
                                SERVICE_PROVIDER_NAME + "\"" + " not found.");
         }
         catch (ServiceRegistryProxyException e)
         {
           System.out.println("ServiceRegistryProxyException: " + e.getMessage());
         }
       }
     }


These demos use the IBM UDDI Test Registry to interact; a predefined login and password have already been registered with the Test Registry.

The SRP, UDDI4J, and WSDL4J are also available as part of the IBM Web Services Toolkit (WSTK) - see Resources for a link. Once WSTK is installed and configured, follow these directions to compile and execute the Service Provider in a Microsoft Windows 2000 environment (The only difference on Linux or Unix would be in the syntax of the commands used to compiled and execute the code):

Compile

Open a shell window and go to the directory where the demos are located, and from the prompt type the following:

 %WSTK_HOME%\bin\wstkenv.bat
 javac -classpath .;%WSTK_CP%;%WSTK_HOME%\uddi4j\lib\uddi4j.jar
 *.java


Execute

In the same shell window now type:

 java -cp .;%WSTK_CP%;%WSTK_HOME%\uddi4j\lib\uddi4j.jar
 ServiceProviderXXXDemo


A successful execution of these demos yields the output shown in Table 3.


Table 3: Demos' output

Demo Output
ServiceProviderPublishDemo Service provider "demo provider" was published
ServiceProviderFindDemo Service Provider Name: demo provider
Description: SRP provider demo
ServiceProviderUnpublishDemo Service provider "demo provider" was unpublished



Back to top


Summary

Now that you are familiar with SRP, I hope that you will find the tool useful. Please feel free to use the code presented here in your own work, and remember to let the Web services team know what other types of articles or tools you would find useful. You'll find links to the WSTK page (and links to feedback forms for the project team) listed in the Resources section.



Resources



About the author

Alfredo da Silva is a software developer at IBM. He is a member of the group responsible for the IBM Web Services Toolkit (WSTK). You can contact Alfredo at afdasilv@us.ibm.com.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top