Implementing a JAXR Client

This section describes the basic steps to follow in order to implement a JAXR client that can perform queries and updates to a UDDI registry. A JAXR client is a client program that can access registries using the JAXR API. This section covers the following topics:

This tutorial does not describe how to implement a JAXR provider. A JAXR provider provides an implementation of the JAXR specification that allows access to an existing registry provider, such as a UDDI or ebXML registry. The implementation of JAXR in the Application Server itself is an example of a JAXR provider.

The Application Server provides JAXR in the form of a resource adapter using the J2EE Connector architecture. The resource adapter is in the directory <J2EE_HOME>/lib/install/applications/jaxr-ra. (<J2EE_HOME> is the directory where the Application Server is installed.)

This tutorial includes several client examples, which are described in Running the Client Examples, and a J2EE application example, described in Using JAXR Clients in J2EE Applications. The examples are in the directory <INSTALL>/j2eetutorial14/examples/jaxr/. (<INSTALL> is the directory where you installed the tutorial bundle.) Each example directory has a build.xml file (which refers to a targets.xml file) and a file in the directory <INSTALL>/j2eetutorial14/examples/jaxr/common/.

Establishing a Connection

The first task a JAXR client must complete is to establish a connection to a registry. Establishing a connection involves the following tasks:

Preliminaries: Getting Access to a Registry

Any user of a JAXR client can perform queries on a registry. To add data to the registry or to update registry data, however, a user must obtain permission from the registry to access it. To register with one of the public UDDI version 2 registries, go to one of the following web sites and follow the instructions:

These UDDI version 2 registries are intended for testing purposes. When you register, you will obtain a user name and password. You will specify this user name and password for some of the JAXR client example programs.

Certificates that allow you to access the IBM registry from a client program are part of the Java Runtime Environment (JRE). To access the Microsoft registry, you must obtain the Microsoft certificates and import them to the JRE. See the following sections for details on how to do this:

Obtaining Certificates for the Microsoft Registry

To obtain the Microsoft certificates, perform these steps:

  1. Open the Internet Explorer browser.
  2. Go to the following URL:

  4. From the browser's File menu, choose Properties.
  5. In the General window, click Certificates.
  6. Click the Certificate Path tab.
  7. For each item in the path that allows you to view its certificate, perform these steps:
    1. Click the General tab of the Certificates window.
    2. Click Install Certificate.
    3. In the Certificate Import Wizard, perform these steps:
      1. Click Next.
      2. Select "Automatically select the certificate store based on the type of certificate" (the default).
      3. Click Finish.
      4. Click OK in the success dialog box.
  8. When you have finished, click OK in the Properties window.
  9. Click the Details tab of the Certificates window.
  10. Click Copy to File.
  11. In the Certificate Export Wizard, perform these steps:
    1. Click Next.
    2. Select "DER encoded binary X.509(.CER)" (the default).
    3. Click Next.
    4. Click Browse and use the file chooser dialog to specify a folder and file name (for example, $HOME/certfile.cer).
    5. Click Next.
    6. Click Finish.
    7. Click OK in the success dialog box.
Importing the Certificates into the JRE

To import the certificates you saved into the Java Runtime Environment (JRE), follow these steps:

  1. Set the JAVA_HOME environment variable and make sure that the location of the JDK bin directory is in your PATH.
  2. Go to the directory $JAVA_HOME/jre/lib/security.
  3. Copy the cacerts file to cacerts.orig to keep a copy of the original certificates.
  4. (UNIX systems only) Make the cacerts file writable (by default it is read-only).
  5. For the certificate file you exported, use the keytool command as follows (all on one line):
  6. keytool -import -keystore cacerts -file location_of_cer_file -alias any_unique_name

    For example:

    keytool -import -keystore cacerts -file ~/cert1.cer -alias mscerts

    When prompted for the keystore password, type changeit.

    When asked "Trust this certificate?" answer yes.

Now standalone Java programs can access the Microsoft registry.

To allow J2EE applications to access the Microsoft registry from a container using the Application Server, follow the steps above, but go to the directory <J2EE_HOME>/domains/domain1/config and specify the file cacerts.jks.

Creating or Looking Up a Connection Factory

A client creates a connection from a connection factory. A JAXR provider can supply one or more preconfigured connection factories. Clients can obtain these factories by looking them up using the Java Naming and Directory Interface (JNDI) API.

At this release of the Application Server, JAXR supplies a connection factory through the JAXR RA, but you need to create a connector resource whose JNDI name is eis/JAXR to access this connection factory from a J2EE application. To look up this connection factory in a J2EE component, use code like the following:

import javax.xml.registry.*;
import javax.naming.*;
  Context context = new InitialContext();
  ConnectionFactory connFactory = (ConnectionFactory) 

Later in this chapter you will learn how to create this connector resource.

To use JAXR in a stand-alone client program, you must create an instance of the abstract class ConnectionFactory:

import javax.xml.registry.*;
ConnectionFactory connFactory = 

Creating a Connection

To create a connection, a client first creates a set of properties that specify the URL or URLs of the registry or registries being accessed. For example, the following code provides the URLs of the query service and publishing service for the IBM test registry. (There should be no line break in the strings.)

Properties props = new Properties();

With the Application Server implementation of JAXR, if the client is accessing a registry that is outside a firewall, it must also specify proxy host and port information for the network on which it is running. For queries it may need to specify only the HTTP proxy host and port; for updates it must specify the HTTPS proxy host and port.


The client then sets the properties for the connection factory and creates the connection:

Connection connection = connFactory.createConnection(); 

The makeConnection method in the sample programs shows the steps used to create a JAXR connection.

Setting Connection Properties

The implementation of JAXR in the Application Server allows you to set a number of properties on a JAXR connection. Some of these are standard properties defined in the JAXR specification. Other properties are specific to the implementation of JAXR in the Application Server. Tables 10-1 and 10-2 list and describe these properties.

Table 10-1 Standard JAXR Connection Properties 
Property Name and Description
Data Type
Default Value
Specifies the URL of the query manager service within the target registry provider.
Specifies the URL of the life-cycle manager service within the target registry provider (for registry updates).
Same as the specified queryManagerURL value
Specifies semantic equivalences of concepts as one or more tuples of the ID values of two equivalent concepts separated by a comma. The tuples are separated by vertical bars:
Provides a hint to the JAXR provider on the authentication method to be used for authenticating with the registry provider.
UDDI_GET_AUTHTOKEN is the only supported value
The maximum number of rows to be returned by find operations. Specific to UDDI providers.
The ID of a ClassificationScheme to be used as the default postal address scheme. See Specifying Postal Addresses  for an example.

Table 10-2 Implementation-Specific JAXR Connection Properties 
Property Name and Description
Data Type
Default Value
Specifies the HTTP proxy host to be used for accessing external registries.
Specifies the HTTP proxy port to be used for accessing external registries; usually 8080.
Specifies the HTTPS proxy host to be used for accessing external registries.
Same as HTTP proxy host value
Specifies the HTTPS proxy port to be used for accessing external registries; usually 8080.
Same as HTTP proxy port value
Specifies the user name for the proxy host for HTTP proxy authentication, if one is required.
Specifies the password for the proxy host for HTTP proxy authentication, if one is required.
Tells the JAXR implementation to look for registry objects in the cache first and then to look in the registry if not found.
Boolean, passed in as String
For details on setting this property, see Defining a Taxonomy.

You set these properties in a JAXR client program. Here is an example:

Properties props = new Properties();
ConnectionFactory factory = ConnectionFactory.newInstance();
connection = factory.createConnection(); 

Obtaining and Using a RegistryService Object

After creating the connection, the client uses the connection to obtain a RegistryService object and then the interface or interfaces it will use:

RegistryService rs = connection.getRegistryService();
BusinessQueryManager bqm = rs.getBusinessQueryManager();
BusinessLifeCycleManager blcm = 

Typically, a client obtains both a BusinessQueryManager object and a BusinessLifeCycleManager object from the RegistryService object. If it is using the registry for simple queries only, it may need to obtain only a BusinessQueryManager object.

Querying a Registry

The simplest way for a client to use a registry is to query it for information about the organizations that have submitted data to it. The BusinessQueryManager interface supports a number of find methods that allow clients to search for data using the JAXR information model. Many of these methods return a BulkResponse (a collection of objects) that meets a set of criteria specified in the method arguments. The most useful of these methods are as follows:

The JAXRQuery program illustrates how to query a registry by organization name and display the data returned. The JAXRQueryByNAICSClassification and JAXRQueryByWSDLClassification programs illustrate how to query a registry using classifications. All JAXR providers support at least the following taxonomies for classifications:

The following sections describe how to perform some common queries:

Finding Organizations by Name

To search for organizations by name, you normally use a combination of find qualifiers (which affect sorting and pattern matching) and name patterns (which specify the strings to be searched). The findOrganizations method takes a collection of findQualifier objects as its first argument and takes a collection of namePattern objects as its second argument. The following fragment shows how to find all the organizations in the registry whose names begin with a specified string, qString, and sort them in alphabetical order.

// Define find qualifiers and name patterns
Collection findQualifiers = new ArrayList();
Collection namePatterns = new ArrayList();

// Find using the name
BulkResponse response = 
    namePatterns, null, null, null, null);
Collection orgs = response.getCollection(); 

A client can use percent signs (%) to specify that the query string can occur anywhere within the organization name. For example, the following code fragment performs a case-sensitive search for organizations whose names contain qString:

Collection findQualifiers = new ArrayList();
Collection namePatterns = new ArrayList();
namePatterns.add("%" + qString + "%");

// Find orgs with name containing qString
BulkResponse response = 
  bqm.findOrganizations(findQualifiers, namePatterns, null,
    null, null, null);
Collection orgs = response.getCollection(); 

Finding Organizations by Classification

To find organizations by classification, you establish the classification within a particular classification scheme and then specify the classification as an argument to the findOrganizations method.

The following code fragment finds all organizations that correspond to a particular classification within the NAICS taxonomy. (You can find the NAICS codes at The NAICS taxonomy has a well-known universally unique identifier (UUID) that is defined by the UDDI specification. The getRegistryObject method finds an object based upon its key. (See Creating an Organization for more information about keys).

String uuid_naics = 
ClassificationScheme cScheme = 
  (ClassificationScheme) bqm.getRegistryObject(uuid_naics,
InternationalString sn = blcm.createInternationalString(
  "All Other Specialty Food Stores"));
Classification classification = 
  blcm.createClassification(cScheme, sn, "445299");
Collection classifications = new ArrayList();
// make JAXR request
BulkResponse response = bqm.findOrganizations(null,
  null, classifications, null, null, null);
Collection orgs = response.getCollection(); 

You can also use classifications to find organizations that offer services based on technical specifications that take the form of WSDL (Web Services Description Language) documents. In JAXR, a concept is used as a proxy to hold the information about a specification. The steps are a little more complicated than in the preceding example, because the client must first find the specification concepts and then find the organizations that use those concepts.

The following code fragment finds all the WSDL specification instances used within a given registry. You can see that the code is similar to the NAICS query code except that it ends with a call to findConcepts instead of findOrganizations. Like the NAICS taxonomy, the classification scheme uddi-org:types has a well-known UUID that is defined by the UDDI specification.

String uuid_types = 
ClassificationScheme uddiOrgTypes =
  (ClassificationScheme) bqm.getRegistryObject(uuid_types,

 * Create a classification, specifying the scheme
 *  and the taxonomy name and value defined for WSDL
 *  documents by the UDDI specification.
Classification wsdlSpecClassification = 
  blcm.createInternationalString("wsdlSpec"), "wsdlSpec");

Collection classifications = new ArrayList();

// Find concepts
BulkResponse br = bqm.findConcepts(null, null, 
  classifications, null, null); 

To narrow the search, you could use other arguments of the findConcepts method (search qualifiers, names, external identifiers, or external links).

The next step is to go through the concepts, find the WSDL documents they correspond to, and display the organizations that use each document:

// Display information about the concepts found
Collection specConcepts = br.getCollection();
Iterator iter = specConcepts.iterator();
if (!iter.hasNext()) {
  System.out.println("No WSDL specification concepts found");
} else {
  while (iter.hasNext()) {
    Concept concept = (Concept);

    String name = getName(concept);

    Collection links = concept.getExternalLinks();
    System.out.println("\nSpecification Concept:\n\tName: " + 
      name + "\n\tKey: " + getKey(concept) + 
      "\n\tDescription: " + getDescription(concept));
    if (links.size() > 0) {
      ExternalLink link = 
        (ExternalLink) links.iterator().next();
      System.out.println("\tURL of WSDL document: '" +
        link.getExternalURI() + "'");

    // Find organizations that use this concept
    Collection specConcepts1 = new ArrayList();
    br = bqm.findOrganizations(null, null, null, 
      specConcepts1, null, null);

    // Display information about organizations

If you find an organization that offers a service you wish to use, you can invoke the service using the JAX-RPC API.

Finding Services and Service Bindings

After a client has located an organization, it can find that organization's services and the service bindings associated with those services.

Iterator orgIter = orgs.iterator();
while (orgIter.hasNext()) {
  Organization org = (Organization);
  Collection services = org.getServices();
  Iterator svcIter = services.iterator();
  while (svcIter.hasNext()) {
    Service svc = (Service);
    Collection serviceBindings = 
    Iterator sbIter = serviceBindings.iterator();
    while (sbIter.hasNext()) {
      ServiceBinding sb = 

Managing Registry Data

If a client has authorization to do so, it can submit data to a registry, modify it, and remove it. It uses the BusinessLifeCycleManager interface to perform these tasks.

Registries usually allow a client to modify or remove data only if the data is being modified or removed by the same user who first submitted the data.

Managing registry data involves the following tasks:

Getting Authorization from the Registry

Before it can submit data, the client must send its user name and password to the registry in a set of credentials. The following code fragment shows how to do this.

String username = "myUserName";
String password = "myPassword";

// Get authorization from the registry
PasswordAuthentication passwdAuth =
  new PasswordAuthentication(username, 

Set creds = new HashSet();

Creating an Organization

The client creates the organization and populates it with data before publishing it.

An Organization object is one of the more complex data items in the JAXR API. It normally includes the following:

For example, the following code fragment creates an organization and specifies its name, description, and primary contact. When a client creates an organization to be published to a UDDI registry, it does not include a key; the registry returns the new key when it accepts the newly created organization. The blcm object in the following code fragment is the BusinessLifeCycleManager object returned in Obtaining and Using a RegistryService Object. An InternationalString object is used for string values that may need to be localized.

// Create organization name and description
InternationalString s =
  blcm.createInternationalString("The Coffee Break");
Organization org = blcm.createOrganization(s);
s = blcm.createInternationalString("Purveyor of " +
  "the finest coffees. Established 1914");

// Create primary contact, set name
User primaryContact = blcm.createUser();
PersonName pName = blcm.createPersonName("Jane Doe");

// Set primary contact phone number
TelephoneNumber tNum = blcm.createTelephoneNumber();
tNum.setNumber("(800) 555-1212");
Collection phoneNums = new ArrayList();

// Set primary contact email address
EmailAddress emailAddress = 
Collection emailAddresses = new ArrayList();

// Set primary contact for organization

Adding Classifications

Organizations commonly belong to one or more classifications based on one or more classification schemes (taxonomies). To establish a classification for an organization using a taxonomy, the client first locates the taxonomy it wants to use. It uses the BusinessQueryManager to find the taxonomy. .

// Set classification scheme to NAICS, using
// well-known UUID of ntis-gov:naics:1997
String uuid_naics = 
ClassificationScheme cScheme = 
  (ClassificationScheme) bqm.getRegistryObject(uuid_naics,

The client then creates a classification using the classification scheme and a concept (a taxonomy element) within the classification scheme. For example, the following code sets up a classification for the organization within the NAICS taxonomy. The second and third arguments of the createClassification method are the name and the value of the concept.

// Create and add classification
InternationalString sn = blcm.createInternationalString(
  "All Other Specialty Food Stores"));
Classification classification =
  blcm.createClassification(cScheme, sn, "445299");
Collection classifications = new ArrayList();

Services also use classifications, so you can use similar code to add a classification to a Service object.

Adding Services and Service Bindings to an Organization

Most organizations add themselves to a registry in order to offer services, so the JAXR API has facilities to add services and service bindings to an organization.

Like an Organization object, a Service object has a name, a description, and a unique key that is generated by the registry when the service is registered. It may also have classifications associated with it.

A service also commonly has service bindings, which provide information about how to access the service. A ServiceBinding object normally has a description, an access URI, and a specification link, which provides the linkage between a service binding and a technical specification that describes how to use the service by using the service binding.

The following code fragment shows how to create a collection of services, add service bindings to a service, and then add the services to the organization. It specifies an access URI but not a specification link. Because the access URI is not real and because JAXR by default checks for the validity of any published URI, the binding sets its validateURI property to false.

// Create services and service
Collection services = new ArrayList();
InternationalString s = 
  blcm.createInternationalString("My Service Name");
Service service = blcm.createService(s);
s = blcm.createInternationalString("My Service Description");

// Create service bindings
Collection serviceBindings = new ArrayList();
ServiceBinding binding = blcm.createServiceBinding();
s = blcm.createInternationalString("My Service Binding " +
// allow us to publish a fictitious URI without an error

// Add service bindings to service

// Add service to services, then add services to organization

Publishing an Organization

The primary method a client uses to add or modify organization data is the saveOrganizations method, which creates one or more new organizations in a registry if they did not exist previously. If one of the organizations exists but some of the data have changed, the saveOrganizations method updates and replaces the data.

After a client populates an organization with the information it wants to make public, it saves the organization. The registry returns the key in its response, and the client retrieves it.

// Add organization and submit to registry
// Retrieve key if successful
Collection orgs = new ArrayList();
BulkResponse response = blcm.saveOrganizations(orgs);
Collection exceptions = response.getException();
if (exceptions == null) {
  System.out.println("Organization saved");

  Collection keys = response.getCollection();
  Iterator keyIter = keys.iterator();
  if (keyIter.hasNext()) {
    javax.xml.registry.infomodel.Key orgKey = 
    String id = orgKey.getId();
    System.out.println("Organization key is " + id);

Publishing a Specification Concept

A service binding can have a technical specification that describes how to access the service. An example of such a specification is a WSDL document. To publish the location of a service's specification (if the specification is a WSDL document), you create a Concept object and then add the URL of the WSDL document to the Concept object as an ExternalLink object. The following code fragment shows how to create a concept for the WSDL document associated with the simple web service example in Creating a Simple Web Service and Client with JAX-RPC. First, you call the createConcept method to create a concept named HelloConcept. After setting the description of the concept, you create an external link to the URL of the Hello service's WSDL document, and then add the external link to the concept.

InternationalString s = 
Concept specConcept = blcm.createConcept(null, s, "");
s = blcm.createInternationalString(
  "Concept for Hello Service");
s = blcm.createInternationalString("Hello WSDL document");
ExternalLink wsdlLink = 
    "http://localhost:8080/hello-jaxrpc/hello?WSDL", s);

Next, you classify the Concept object as a WSDL document. To do this for a UDDI registry, you search the registry for the well-known classification scheme uddi-org:types using its key. (The UDDI term for a classification scheme is tModel.) Then you create a classification using the name and value wsdlSpec. Finally, you add the classification to the concept.

String uuid_types = 
ClassificationScheme uddiOrgTypes =
  (ClassificationScheme) bqm.getRegistryObject(uuid_types,
Classification wsdlSpecClassification = 

Finally, you save the concept using the saveConcepts method, similarly to the way you save an organization:

Collection concepts = new ArrayList();
BulkResponse concResponse = blcm.saveConcepts(concepts); 

After you have published the concept, you normally add the concept for the WSDL document to a service binding. To do this, you can retrieve the key for the concept from the response returned by the saveConcepts method; you use a code sequence very similar to that of finding the key for a saved organization.

String conceptKeyId = null;
Collection concExceptions = concResponse.getExceptions();
javax.xml.registry.infomodel.Key concKey = null;
if (concExceptions == null) {
  System.out.println("WSDL Specification Concept saved");

  Collection keys = concResponse.getCollection();
  Iterator keyIter = keys.iterator();
  if (keyIter.hasNext()) {
    concKey = 
    conceptKeyId = concKey.getId();
    System.out.println("Concept key is " + conceptKeyId);

Then you can call the getRegistryObject method to retrieve the concept from the registry:

Concept specConcept = 
  (Concept) bqm.getRegistryObject(conceptKeyId, 

Next, you create a SpecificationLink object for the service binding and set the concept as the value of its SpecificationObject:

SpecificationLink specLink = 

Now when you publish the organization with its service and service bindings, you have also published a link to the WSDL document. Now the organization can be found via queries such as those described in Finding Organizations by Classification.

If the concept was published by someone else and you don't have access to the key, you can find it using its name and classification. The code looks very similar to the code used to search for a WSDL document in Finding Organizations by Classification, except that you also create a collection of name patterns and include that in your search. Here is an example:

// Define name pattern
Collection namePatterns = new ArrayList();

BulkResponse br = bqm.findConcepts(null, namePatterns, 
  classifications, null, null); 

Removing Data from the Registry

A registry allows you to remove from it any data that you have submitted to it. You use the key returned by the registry as an argument to one of the BusinessLifeCycleManager delete methods: deleteOrganizations, deleteServices, deleteServiceBindings, deleteConcepts, and others.

The JAXRDelete sample program deletes the organization created by the JAXRPublish program. It deletes the organization that corresponds to a specified key string and then displays the key again so that the user can confirm that it has deleted the correct one.

String id = key.getId();
System.out.println("Deleting organization with id " + id);
Collection keys = new ArrayList();
BulkResponse response = blcm.deleteOrganizations(keys);
Collection exceptions = response.getException();
if (exceptions == null) {
  System.out.println("Organization deleted");
  Collection retKeys = response.getCollection();
  Iterator keyIter = retKeys.iterator();
  javax.xml.registry.infomodel.Key orgKey = null;
  if (keyIter.hasNext()) {
    orgKey = 
    id = orgKey.getId();
    System.out.println("Organization key was " + id);

A client can use a similar mechanism to delete concepts, services, and service bindings.

Using Taxonomies in JAXR Clients

In the JAXR API, a taxonomy is represented by a ClassificationScheme object. This section describes how to use the implementation of JAXR in the Application Server

Defining a Taxonomy

The JAXR specification requires that a JAXR provider be able to add user-defined taxonomies for use by JAXR clients. The mechanisms clients use to add and administer these taxonomies are implementation-specific.

The implementation of JAXR in the Application Server uses a simple file-based approach to provide taxonomies to the JAXR client. These files are read at runtime, when the JAXR provider starts up.

The taxonomy structure for the Application Server is defined by the JAXR Predefined Concepts DTD, which is declared both in the file jaxrconcepts.dtd and, in XML schema form, in the file jaxrconcepts.xsd. The file jaxrconcepts.xml contains the taxonomies for the implementation of JAXR in the Application Server. All these files are contained in the <J2EE_HOME>/lib/jaxr-impl.jar file. This JAR file also includes files that define the well-known taxonomies used by the implementation of JAXR in the Application Server: naics.xml, iso3166.xml, and unspsc.xml.

The entries in the jaxrconcepts.xml file look like this:

<JAXRClassificationScheme id="schId" name="schName">
<JAXRConcept id="schId/conCode" name="conName" 
parent="parentId" code="conCode"></JAXRConcept>

The taxonomy structure is a containment-based structure. The element PredefinedConcepts is the root of the structure and must be present. The JAXRClassificationScheme element is the parent of the structure, and the JAXRConcept elements are children and grandchildren. A JAXRConcept element may have children, but it is not required to do so.

In all element definitions, attribute order and case are significant.

To add a user-defined taxonomy, follow these steps.

  1. Publish the JAXRClassificationScheme element for the taxonomy as a ClassificationScheme object in the registry that you will be accessing. To publish a ClassificationScheme object, you must set its name. You also give the scheme a classification within a known classification scheme such as uddi-org:types. In the following code fragment, the name is the first argument of the LifeCycleManager.createClassificationScheme method call.
  2. ClassificationScheme cScheme =
        "A Classification Scheme");
    ClassificationScheme uddiOrgTypes =
    if (uddiOrgTypes != null) {
      Classification classification =
          "postalAddress", "postalAddress" );
      ExternalLink externalLink =
          "My Scheme");
      Collection schemes = new ArrayList();
      BulkResponse br =

    The BulkResponse object returned by the saveClassificationSchemes method contains the key for the classification scheme, which you need to retrieve:

    if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
      System.out.println("Saved ClassificationScheme");
      Collection schemeKeys = br.getCollection();
      Iterator keysIter = schemeKeys.iterator();
      while (keysIter.hasNext()) {
        javax.xml.registry.infomodel.Key key =
        System.out.println("The postalScheme key is " +
        System.out.println("Use this key as the scheme" +
          " uuid in the taxonomy file");

  3. In an XML file, define a taxonomy structure that is compliant with the JAXR Predefined Concepts DTD. Enter the ClassificationScheme element in your taxonomy XML file by specifying the returned key ID value as the id attribute and the name as the name attribute. For the foregoing code fragment, for example, the opening tag for the JAXRClassificationScheme element looks something like this (all on one line):
  4. <JAXRClassificationScheme

    The ClassificationScheme id must be a universally unique identifier (UUID).

  5. Enter each JAXRConcept element in your taxonomy XML file by specifying the following four attributes, in this order:
    1. id is the JAXRClassificationScheme id value, followed by a / separator, followed by the code of the JAXRConcept element.
    2. name is the name of the JAXRConcept element.
    3. parent is the immediate parent id (either the ClassificationScheme id or that of the parent JAXRConcept).
    4. code is the JAXRConcept element code value.
    5. The first JAXRConcept element in the naics.xml file looks like this (all on one line):

      name="Agriculture, Forestry, Fishing and Hunting"

  6. To add the user-defined taxonomy structure to the JAXR provider, specify the connection property com.sun.xml.registry.userTaxonomyFilenames in your client program. You set the property as follows:
  7. props.setProperty

    Use the vertical bar (|) as a separator if you specify more than one file name.

Specifying Postal Addresses

The JAXR specification defines a postal address as a structured interface with attributes for street, city, country, and so on. The UDDI specification, on the other hand, defines a postal address as a free-form collection of address lines, each of which can also be assigned a meaning. To map the JAXR PostalAddress format to a known UDDI address format, you specify the UDDI format as a ClassificationScheme object and then specify the semantic equivalences between the concepts in the UDDI format classification scheme and the comments in the JAXR PostalAddress classification scheme. The JAXR PostalAddress classification scheme is provided by the implementation of JAXR in the Application Server.

In the JAXR API, a PostalAddress object has the fields streetNumber, street, city, state, postalCode, and country. In the implementation of JAXR in the Application Server, these are predefined concepts in the jaxrconcepts.xml file, within the ClassificationScheme named PostalAddressAttributes.

To specify the mapping between the JAXR postal address format and another format, you set two connection properties:

For example, suppose you want to use a scheme named MyPostalAddressScheme, which you published to a registry with the UUID uuid:f7922839-f1f7-9228-c97d-ce0b4594736c.

<JAXRClassificationScheme id="uuid:f7922839-f1f7-9228-c97d-
ce0b4594736c" name="MyPostalAddressScheme"> 

First, you specify the postal address scheme using the id value from the JAXRClassificationScheme element (the UUID). Case does not matter:


Next, you specify the mapping from the id of each JAXRConcept element in the default JAXR postal address scheme to the id of its counterpart in the scheme you published:

  "urn:uuid:PostalAddressAttributes/StreetNumber," +
StreetAddressNumber|" +
  "urn:uuid:PostalAddressAttributes/Street," +
StreetAddress|" +
  "urn:uuid:PostalAddressAttributes/City," +
  "urn:uuid:f7922839-f1f7-9228-c97d-ce0b4594736c/City|" +
  "urn:uuid:PostalAddressAttributes/State," +
  "urn:uuid:f7922839-f1f7-9228-c97d-ce0b4594736c/State|" +
  "urn:uuid:PostalAddressAttributes/PostalCode," +
  "urn:uuid:f7922839-f1f7-9228-c97d-ce0b4594736c/ZipCode|" +
  "urn:uuid:PostalAddressAttributes/Country," +

After you create the connection using these properties, you can create a postal address and assign it to the primary contact of the organization before you publish the organization:

String streetNumber = "99";
String street = "Imaginary Ave. Suite 33";
String city = "Imaginary City";
String state = "NY";
String country = "USA";
String postalCode = "00000";
String type = "";
PostalAddress postAddr = 
  blcm.createPostalAddress(streetNumber, street, city, state,
    country, postalCode, type);
Collection postalAddresses = new ArrayList();

If the postal address scheme and semantic equivalences for the query are the same as those specified for the publication, a JAXR query can then retrieve the postal address using PostalAddress methods. To retrieve postal addresses when you do not know what postal address scheme was used to publish them, you can retrieve them as a collection of Slot objects. The sample program shows how to do this.

In general, you can create a user-defined postal address taxonomy for any PostalAddress tModels that use the well-known categorization in the uddi-org:types taxonomy, which has the tModel UUID uuid:c1acf26d-9672-4404-9d70-39b756e62ab4 with a value of postalAddress. You can retrieve the tModel overviewDoc, which points to the technical detail for the specification of the scheme, where the taxonomy structure definition can be found. (The JAXR equivalent of an overviewDoc is an ExternalLink.)