Developing Web Services with Java APIs for XML Using WSDP

Querying the Registry

Upon successful connection with a registry, the next step is to query the registry to locate specific vendors and/or services. The ServiceRegistry interface in the javax.xml.registry package enables the client program to obtain the interfaces being used by the Connection class to connect to the registry. The BusinessQueryManager interface in the javax.xml.registry package supports various methods to search for data in a registry using the JAXR information model. In this section, we discuss how these interfaces can be used to query a registry.

Finding a Service Using a Simple Query

We begin with a simple query that tries to search for organizations in the IBM registry whose name begins with the letter A. First of all, we obtain the ServiceRegistry object and use it to create a BusinessQueryManager object as shown in the following lines of code:

RegistryService myservice = connection.getRegistryService(); BusinessQueryManager bqmanager = myservice.getBusinessQueryManager();

Here, connection is the connection object used to connect to the registry. We now create two Collection objects, the first one storing the sorting order for the search results, and the second one the pattern that we want to search for in an organization s name:

Collection findQualifier = new ArrayList();findQualifier.add(FindQualifier.SORT_BY_NAME_DESC);Collection namePattern = new ArrayList();namePattern.add("A");

The preceding code specifies that the results be sorted alphabetically and designates A as the string pattern we are searching for. Next, we use the findOrganizations() method of the BusinessQueryManager object to search the registry.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Search Engine Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.