JAXR and ebXML Registry

In practical terms, the JAXR information model is based on the ebXML information model. This makes sense from two perspectives: the ebXML v. 2.0 Registry Information Model (RIM) is functionally larger than the UDDI v. 2.0 information model, and developing such detailed models based on community consensus takes time.

As mentioned previously, all the previous discussion about using JAXR and UDDI remains unchanged with an ebXML registry, because of the API's abstraction. In this section, we will discuss how client apps can leverage some of JAXR's level 1 capability features.

Java Start Sidebar

The ebXML Registry Service and Registry Information Model specifications can be found at

Java End Sidebar

Publishing Organizations in ebXML Registries

One of the significant differences between UDDI and ebXML registries is how client apps are authenticated. While UDDI requires only password-based authentication, the ebXML Registry Service allows for digital certificates to be used in the SOAP headers. The SOAP message in Listing 12.7 shows how the X.509 certificate is included using XML D-Sig specifications.

Listing 12.7: SOAP request to the registry with the X.509 certificate
<soap-env:Envelope xmlns:soap-env="">
 <ds:Signature xmlns:ds="">
 <ds:Reference URI="">
 <ds:DigestMethod Algorithm="">
 <RegistryPackage id="urn:uuid:bfef9997-508d-4131-a826-edebc7a47836" objectType=
 <LocalizedString charset="UTF-8" lang="en-us"
 value="Flute Bank Agreements">
 <LocalizedString charset="UTF-8" lang="en-us" value="">

Java End example

Let us look at how a client can publish Organization information in the ebXML registry using JAXR. Listing 12.8 shows how the JAXR provider for ebXML (available under open source) can be used. The example is identical to Listing 12.1, which published the information to a UDDI registry. The only difference is the manner in which the connection is passed the user's credentials for authentication. Instead of a username and password, the user sends the X.509 certificate.

Listing 12.8: Using the open source JAXR provider to include the X.509 certificate
// other imports public class ebXMLPublishOrg {
public static void main (String args[]){
// keystore location and alias
// Start JAXR provider imsplementation specific code
 String alias = "mykey";
 String location="c:/temp/rr/jaxr/keystore.jks";
 String storepass="ebxmlrr";
 String keypass="password";
HashSet creds = new HashSet();
// get the keystore KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(new FileInputStream(location), storepass.toCharArray());
X509Certificate cert =(X509Certificate)keyStore.getCertificate(alias);
PrivateKey privateKey=
 X500PrivateCredential credential=
 new X500PrivateCredential(cert,privateKey,alias);
// End JAXR provider implementation specific code
// Create the connection factory, which can be set by the system property
// com.sun.xml.registry.ebxml.ConnectionFactoryImpl
 ConnectionFactory factory = ConnectionFactory.newInstance();
 Connection connection = connFactory.createConnection();
// create organization and other objects with BusinessLifeCyleManager and
// use the BusinessLifeCyleManager.saveOrganizations(orgs) method

Java End example
Java Start Sidebar

Digital certificates are based on public-key crytography, in which an individual is issued a private and a public key. X.509 is a widely used industry standard maintained by the International Telecommunications Union (ITU). It is used in various code-signing schemes, (e.g., signed JAR files and Microsoft Authenticode) and protocols such as secure email (PEM and S/MIME) and SSL. The certificate contains information about the issuer, the validity period, the subject's distinguished name (e.g., CN=John Malkovich, OU=Billing Department, O=Flute Bank, C=US) and the subject's public key. Typically, authentication is performed by the user's sending the X.509 certificate containing the public key. The server sends a challenge back to the user that contains a randomly generated sequence of characters. The user then encrypts it with the private key and returns the encrypted string to the server. If the encrypted string can be successfully decrypted using the public key supplied in the certificate, the server can be sure the user is in possession of the private key and is the person to whom the certificate was issued. Working with X.509 Certificates

The JDK comes with a the tool called keytool that can be used to create public-private key pairs; display, import, and export X.509 v. 1, v. 2, and v. 3 certificates stored as files; and generate new self-signed v. 1 certificates. keytool also manages the keystore, which is a protected database that holds keys and certificates. The API for using these certificates in Java is included in the core package,

Java End Sidebar

Publishing Content to ebXML Registry

One of the advantages of using an ebXML registry is that it can store arbitrary content, such as business process descriptions (BPML documents), and business agreements, such as the CPP and CPA agreements used in ebXML messaging systems. This is different from storing WSDL in UDDI, in the sense that the actual business document is stored in the repository, which the registry service exposes. For example, the code in Listing 12.3 publishes a URL only to the WSDL document, whereas in an ebXML registry, the actual WSDL document may be published to the registry. In this sense, the ebXML registry plays a sort of content management role. In JAXR, the ExtrinsicObject is used to model the metadata representing such content. Let us look at some code extracts that show how this can be used. Flute Bank can choose to store its CPP/CPA with OfficeMin as the following code shows.

// Create a connection and authenticate with the registry
// Obtain the BusinessLifeCyleManager instance from the connection
// Now get the XML file URL url = getClass().getResource("/agreements/officemin.xml");
DataHandler handler = new DataHandler(url);
// Create an ExtrinsicObject ExtrinsicObject obj = lifecyclemgr.createExtrinsicObject(handler);
// Save the arbitrary content Collection data = new ArrayList();
BulkResponse response = lifecyclemgr.saveObjects(data);
 System.out.println("CPP successfully saved");
 System.out.println("ID is :+obj.getKey().getId()");

Note that in the above example, the resource can be any arbitrary content, such as graphic files, XML schemas, or Word documents. In practical terms, content will be grouped into RegistryPackage objects that can be associated with any RegistryObject. RegistryPackages are a powerful level 1 feature. Any registry object can have multiple RegistryPackages associated with it and can also be associated with multiple packages. Therefore, business documents such as privacy policies, grouped under a package named "Policies" and associated with an Organization, can be retrieved as shown below:

// Locate the Organization
 BulkResponse response = querymgr.findOrganizations(findqualifier,
 searchpattern, null, null, null,
// Iterate and get to the individual Organization
 Organization org = (Organization);
 Collection packages =org.getRegistryPackages();
// Iterate and get to the package we are interested in
 Collection extobjects=package.getRegistryObjects();
// Iterate and get individual ExtrinsicObject elements
// get underlying content
 DataHandler handler= obj.getRepositoryItem();

Documents such as the CPP and CPA, which relate to the Service, can also be queried and stored in a similar manner under the associated Service object (which is also an instance of a RegistryObject).

As a general coding note, while interacting with the ebXML registry, client apps will rely more on the generic methods defined in the LifeCycleManager rather than the subclass BusinessLifeCycleManager to create and save objects. Similarly, they will rely more on the declarative queries and the DeclarativeQueryManager looked at earlier to find data in the registry, as opposed to the BusinessQueryManager looked at for UDDI.

A Complete ebXML Example

Let us look at a complete example of publishing information to an ebXML registry, using the open source JAXR provider and ebXML registry implementation. We have slightly modified the UDDI example from Listing 12.1, for two reasons: the ebXML registry has tighter validation rules than UDDI (e.g., a contact person for an Organization is required), and we wanted to show the use of some level 1 capabilities. Listing 12.9 publishes Flute Bank's information, its BillPay service information, some associated documents (we will use Flute's BPSS and CPA XML documents used in ), and creates a package object in the registry and an association. For the sake of brevity, we have not included the SOAP messages exchanged between the client and the registry. Upon successful execution, the results can be viewed using the graphical registry browser, as Screenshot shows.

Listing 12.9: Publishing with the JAXR provider
import javax.xml.registry.infomodel.*;
import javax.xml.registry.*;
import java.util.*;
import javax.activation.*;
public class ebXMLPublishOrg{
 private static final String QUERY_URL= "http://localhost:9090/ebxmlrr/registry";
 private static final String PUBLISH_URL="http://localhost:9090/ebxmlrr/registry";
 public static void main(String[] args) throws Exception {
// Set the properties for the ConnectionFactory Properties environment = new Properties();
environment.setProperty("javax.xml.registry.queryManagerURL", QUERY_URL);
environment.setProperty("javax.xml.registry.lifeCycleManagerURL", PUBLISH_URL);
// Instantiate the factory and create a connection from it
 ConnectionFactory connfactory = ConnectionFactory.newInstance();
 Connection conn = connfactory.createConnection();
// Authenticate the username and password with the registry
/////////////// Start JAXR provider implementation-specific code
 String alias = "mykey";
 String location="c:/temp/rr/jaxr/keystore.jks";
 String storepass="ebxmlrr";
 String keypass="password";
 HashSet creds = new HashSet();
// get the keystore
 KeyStore keyStore = KeyStore.getInstance("JKS");
 keyStore.load(new FileInputStream(location), storepass.toCharArray());
 X509Certificate cert =(X509Certificate)keyStore.getCertificate(alias);
 PrivateKey privateKey =
 X500PrivateCredential credential=
 new X500PrivateCredential(cert,privateKey,alias);
////////////// END JAXR provider implementation-specific code
// Obtain a reference to the RegistryService, the BusinessLifeCycleManager, and
// the BusinessQueryManager RegistryService registryservice = conn.getRegistryService();
BusinessLifeCycleManager lifecyclemgr =
BusinessQueryManager querymgr = registryservice.getBusinessQueryManager();
// Create a user object User contact = lifecyclemgr.createUser();
PersonName name = lifecyclemgr.createPersonName("John Malkovich");
InternationalString contactdescription = lifecyclemgr.createInternationalString
 ("The primary contact person for Flute Web services");
// Create and set the user's telephone number TelephoneNumber telnum = lifecyclemgr.createTelephoneNumber();
Collection phonenumbers = new ArrayList();
// Create and set the user's email address EmailAddress email = lifecyclemgr.createEmailAddress(
Collection emaillist = new ArrayList();
PostalAddress addr = lifecyclemgr.createPostalAddress("64"," Bit
 Street"," Windsor"," CT"," USA","03060"," Office Address");
ArrayList addresses = new ArrayList();
// Create an organization object Organization company = lifecyclemgr.createOrganization("Flute Bank");
InternationalString description = lifecyclemgr.createInternationalString
 "A fictitious bank used for examples in the tutorial Java Web Services Architecture, shared by Morgan Kaufman, . The authors can be reached at OR ");
// Set the user as the primary contact for the organization. User's address and
// company address are same company.setPrimaryContact(contact);
ExternalLink website = lifecyclemgr.createExternalLink("",
"Flute Bank Inc");
// We now have the objects representing our information model
// To publish it, we must classify it. We decide to use the
// NAICS scheme ClassificationScheme scheme =
 querymgr.findClassificationSchemeByName(null," ntis-gov:naics");
// Create the classification using the above scheme and pass the relevant
// category code and description Classification classification =
(Classification)lifecyclemgr.createClassification(scheme,"Finance and Insurance", "52");
Collection classificationlist = new ArrayList();
// Create the concrete service (this maps to the businessService)
Service service = lifecyclemgr.createService("Billpayservice");
InternationalString servicedescription =
 lifecyclemgr.createInternationalString("A Web
 service allowing account holders to pay bills online");
ExternalLink link1 = lifecyclemgr.createExternalLink
 ("", "Service WSDL");
// Create the service bindings for the Web service ServiceBinding binding = lifecyclemgr.createServiceBinding();
InternationalString bindingdescription =
 lifecyclemgr.createInternationalString("HTTP bindings for the Billpayservice Web
// replace with the actual URL where the service is deployed binding.setAccessURI("");
DataHandler upload1 = new DataHandler(new FileDataSource("C:/rr/jaxr/build/test/
DataHandler upload2 = new DataHandler(new FileDataSource("C:/rr/jaxr/build/test/
// Create an ExtrinsicObject ExtrinsicObject obj1 = lifecyclemgr.createExtrinsicObject(upload1);
ExtrinsicObject obj2 = lifecyclemgr.createExtrinsicObject(upload2);
RegistryPackage docs =lifecyclemgr.createRegistryPackage("BusinessDocuments");
Concept assType = querymgr.findConceptByPath("/AssociationType/packages");
Association ass = lifecyclemgr.createAssociation(docs, assType);
// make the final call to the registry and get a response
// This could have been used instead
//BulkResponse response = lifecyclemgr.saveOrganizations(organizationlist);
// We show the more general method below ArrayList objs = new ArrayList();
BulkResponse response = lifecyclemgr.saveObjects(objs);
if (response.getStatus()==JAXRResponse.STATUS_SUCCESS)
 System.out.println("The request was processed successfully");
// Finally, close the connection conn.close();

Java End example
Java Click To expand
Screenshot: ebXML registry browser

Mapping of ebXML Registry Information Model to JAXR

No mapping is required from the JAXR model to the ebXML Registry Information Model, because they are identical (e.g., Organization interface in JAXR maps to an Organization object in RIM, etc.) Also, JAXR supports all features and functionality defined by OASIS for the ebXML registry.