Web services take float with JAXR

Use JAXR to find and register Web services

1 2 3 Page 3
Page 3 of 3

Only capability-level 1 JAXR providers support internal taxonomies (internal ClassificationSchemes). Internal classification schemes are defined as a Concept hierarchy. When a registry stores classification information internally, it can perform validation whenever it classifies a registry object. External classifications don't offer that capability; instead of Concepts, they rely on String values to build a hierarchy under a classification scheme. Figure 7 illustrates a travel-related industry taxonomy based on the North American Industry Classification System (NAICS).

Figure 7. Internal and external classifications in a JAXR registry. Click on thumbnail to view full-size image.

The following code segment adds Magellan Travel to Web service registries via JAXR. After creating the organization, JAXR classifies Magellan as a travel agency, or code 56151 according to the NAICS (an external taxonomy):

try {
     Organization org =
          businessLifeCycleManager.createOrganization("Magellan Travel");
     InternationalString str =
          businessLifeCycleManager.createInternationalString("A cruise ship reservation system");
     org.setDescription(str);
     //Primary contact
     User primaryContact = businessLifeCycleManager.createUser();
     PersonName pName = businessLifeCycleManager.createPersonName("Fernando Magellan");
     primaryContact.setPersonName(pName);
     TelephoneNumber tNum = businessLifeCycleManager.createTelephoneNumber();
     tNum.setNumber("213-747-5516");
     Collection phoneNumbers = new ArrayList();
     phoneNumbers.add(tNum);
     primaryContact.setTelephoneNumbers(phoneNumbers);
     EmailAddress emailAddress =
          businessLifeCycleManager.createEmailAddress("fernando@magellan.com");
     Collection emailAddresses = new ArrayList();
     emailAddresses.add(emailAddress);
     primaryContact.setEmailAddresses(emailAddresses);
     org.setPrimaryContact(primaryContact);
     //Assign classification scheme
     ClassificationScheme sc =
          businessQueryManager.findClassificationSchemeByName("ntis-gov:naics");
     Classification classification =
          (Classification)businessLifeCycleManager.createClassification(sc, 
            "Travel Agencies", "56151");
     Collection classifications = new ArrayList();
     classifications.add(classification);
     org.addClassifications(classifications);
     //Save new organization
     Collection orgs = new ArrayList();
     orgs.add(org);
     BulkResponse response = businessLifeCycleManager.saveOrganizations(orgs);
     Collection exceptions = response.getException();
     if (exceptions == null) {
          System.out.println("Organization saved");
      } else {
          for (Iterator iterator = exceptions.iterator(); iterator.hasNext();) {
              JAXRException e = (JAXRException) iterator.next();
               System.out.println(e.getMessage());
          }
           System.out.println("Couldn't save organization.");
       }
} catch (JAXRException e) {
     e.printStackTrace();
}

The final code example finds all companies belonging to the deep-sea passenger transportation industry (or code 483112 in the NAICS taxonomy):

try {
     //Searching by classification
     String schemeName = "uddi-org:types";
     ClassificationScheme uddiOrgType =
          businessQueryManager.findClassificationSchemeByName(schemeName);
     Classification classification =
          businessLifeCycleManager.createClassification(uddiOrgType,
          "Deep sea passenger transportation", "483112");
     Collection classifications = new ArrayList();
     classifications.add(classification);
     BulkResponse res = businessQueryManager.findOrganizations(
           null,
           null,
           classifications,
           null,
           null,
           null);
     Collection orgs = res.getCollection();
     Iterator it = orgs.iterator();
     while (it.hasNext()) {
          Organization o = (Organization)it.next();
          System.out.println("Organization name: " + o.getName().getValue());
     }
} catch (JAXRException e) {
     e.printStackTrace();
}

Additional benefits

The JAXR API has several additional capabilities Magellan Travel will find useful, including context-aware classifications. Consider a cruise line that classifies itself via a geographic taxonomy under Japan. From that information alone, you cannot tell whether the cruise line offers trips to Japan, operates ships inside Japan, or has its fleet under Japanese registration. By adding an extra link and classifying that geographic classification itself, you easily clarify this situation. (Recall that Classification is just another RegistryItem; thus, you can call addClassification() on it too.)

Another important JAXR feature lets you create associations between registry objects. If a cruise line has partner arrangements with local vendors, for instance, Magellan Travel would consider those pre-existing relationships when making business arrangements. Figure 8 shows how a JAXR-based registry browser displays those business associations.

Figure 8. A JAXR registry browser displaying registry object associations, showing how companies associate in a business relationship. Click on thumbnail to view full-size image.

Once Magellan Travel discovers a cruise line of interest, it would like to initiate a business relationship with that company. In my next column, I will focus on how the Web service specifications and access URIs published in registries lets Magellan's programmers make remote method invocations to a newly discovered cruise company's Web service via JAX/RPC (Java API for XML-based RPC).

Learn more about this topic

1 2 3 Page 3
Page 3 of 3