Code Snippet 3:
1.9 JAXR API
The Java API for XML Registries (JAXR) API is an abstract uniform Java API. It has a single set of APIs that can access many XML registries, including UDDI and ebXML registries.
1.9.1 JAXR Architecture
There are two parts in JAXR architecture, namely JAXR client and JAXR provider. First, the client uses JAXR interfaces and classes to request access to a registry. A connection is created by using the createConnection() method through the ConnectionFactory interface.
After receiving the requests, JAXR provider transforms these methods into registry-specific methods and transfers them to the target registry providers. The registry receives the
Introduction to Web Services
Session 01
The registry returns the response to JAXR provider where the response is transformed to JAXR response. The provider sends this response back to the JAXR client.
The layered architecture of JAXR accommodates different functionalities from different registry providers. There can be two capability profiles, namely level 0 and level 1. Level 0’s basic features support business-focused APIs, whereas, level 1’s advanced features support generic APIs. Figure 1.13 illustrates the JAXR architecture.
Figure 1.13: JAXR Architecture
1.9.2 JAXR Information Model
The JAXR information model is based on the ebXML Registry Information Model (RIM).
It also supports UDDI and has all the data types defined in the UDDI Data Structure Specification. It creates JAXR information model objects when the JAXR client invokes life-cycle and query management methods on the JAXR provider.
JAXR information model provides a more intuitive and natural interface to developers.
Some of the interfaces that define the JAXR information model are described in table 1.9.
Interface Description
Organization Organization instances are RegistryObjects that provide information on an organization that has been published to the underlying registry.
Service Service instances are RegistryObjects that provide information on services offered by an organization.
Introduction to Web Services
Session 01
Interface Description
ServiceBinding ServiceBinding instances are RegistryObjects that represent technical information on how to access a specific interface offered by a Service instance.
Concept Concept instances represent an arbitrary notion or concept. It can be virtually anything.
Classification Scheme
ClassificationScheme instances represent a taxonomy that can be used to classify or categorize RegistryObject instances.
ExternalLink ExternalLink instances provide a link to content managed outside the registry using a URI.
ExternalIdentifier ExternalIdentifier instances provide identification information to a RegistryObject.
Classification Classification instances classify a RegistryObject instance using a classification scheme
PostalAddress PostalAddress instances provide address information for a user and an Organization.
Table 1.9: Interfaces of JAXR API
The UDDI provider exposes the registry though a Web-based HTML interface. Then, the registry may be queried for different fields by using the relevant methods from the BusinessQuery Manager interface.
1.9.3 Connecting to Registry
A JAXR client establishes a connection with a registry by:
Creating a connection factory
Configuring connection factory
Creating a connection
Obtaining a service object Creating Connection Factory
Many of the JAXR providers supply one or many preconfigured connection factories. To create an instance of connection factory, first connect to the JNDI service by creating an instance of initial context. Next, use the instance to lookup the connection factory using its JNDI name.
Configuring Connection Factory
To connect to the registry, creates a set of properties that will be used to specify the URL or URLs of the registries that are being accessed by the application. For example, you can use the queryManagerURL and lifeCycleManagerURL properties of the Properties object to specify the URLs of the query service and the publishing service for the registry.
Introduction to Web Services
Session 01
Creating a Connection
The next step is to create a connection instance. This is done by invoking the createConnection() method on the connection factory instance.
Obtaining Service Object
The JAXR client uses the getRegistryService() method to retrieve a RegistryService object.
The registry service instance is used to create instances of BusinessQueryManager and BusinessLifeCycleManager. The service information from the registry is retrieved by using BusinessQueryManager instance. The BusinessLifeCycleManager instance is used to add, edit, or remove service information from the registry.
1.9.4 Publishing Data on Registry
After getting registry object, service and service provider’s information can be added to it.
This can be done by:
Creating an organization instance
Associating one or more services with it
Adding this information to the registry Creating an Organization Instance
As the first step, an organization is created by using createOrganization() method on the BusinessLifeCycleManager instance. Then, an instance of User class is created and setter methods are used to store contact information about the organization. This information is associated with the organization by invoking the setPrimaryContact() method and passing the user instance to it.
Adding Services and Service Binding
An instance to store various services of an organization is created. Then, a service instance is created by using the createService() method. The setDescription() method describes the service provided. The name, description, and a unique key for each service object are generated when it is registered. When the user searches for a service, the registry sets the service’s name. Service bindings are stored using a new collection instance.
The registry is informed to ignore Uniform Resource Identifier (URI) validation. A fictitious URI is provided for the service and service binding is added to the service binding collection instance. Finally, the service collection instance is passed to the addServices() method, which binds the organization instance with the service instance.
Publishing an Organization
A collection instance is created to store organization information. This instance contains contact information, service, and service binding information. These details are saved to the registry by using saveOrganizations() method. Then, the getExceptions() method is used to check whether the organization information was saved successfully. The method returns null if the details are saved successfully.
Introduction to Web Services
Session 01
Then, the collection of keys is retrieved using the getCollection() method. A key is created for every organization instance stored in the registry. An iterator called keyIter is created using the iterator() method. The elements in the keyIter instance can be retrieved using the getID() method.