Use the JAXR provider for UDDI
To get started with the Java API for XML Registries (JAXR) provider, we can use a sample program. We also need to consider class libraries, authentication and security, internal taxonomies, and logging and messages.
Deprecated feature: From WebSphere Application Server v8.0, Java API for XML Registries (JAX-R) APIs are deprecated. The Java EE 6 platform began the deprecation process for JAX-R because it is based on UDDI 2 technology, which is no longer relevant. If the applications use JAX-R, then we might consider using UDDI 3.depfeat
Tasks
- To obtain the ConnectionFactory instance, create a connection to the registry, and save an organization in the registry, see the following sample program.
(iSeries) Replace all references to localhost with references to the specific IBM i machine that the UDDI registry runs on.
import java.net.PasswordAuthentication; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Properties; import java.util.Set; import javax.xml.registry.BulkResponse; import javax.xml.registry.BusinessLifeCycleManager; import javax.xml.registry.Connection; import javax.xml.registry.ConnectionFactory; import javax.xml.registry.JAXRException; import javax.xml.registry.RegistryService; import javax.xml.registry.infomodel.Key; import javax.xml.registry.infomodel.Organization; public class JAXRSample { public static void main(String[] args) throws JAXRException { //Tell the ConnectionFactory to use the JAXR provider for UDDI System.setProperty("javax.xml.registry.ConnectionFactoryClass", "com.ibm.xml.registry.uddi.ConnectionFactoryImpl"); ConnectionFactory connectionFactory = ConnectionFactory.newInstance(); //Set the URLs for the UDDI inquiry and publish APIs. //These must be the URLs of the UDDI version 2 APIs. Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", "http://localhost:9080/uddisoap/inquiryapi"); props.setProperty("javax.xml.registry.lifeCycleManagerURL", "http://localhost:9080/uddisoap/publishapi"); connectionFactory.setProperties(props); //Create a Connection to the UDDI registry accessible at the previous URLs. Connection connection = connectionFactory.createConnection(); //Set the user ID and password used to access the UDDI registry. PasswordAuthentication pa = new PasswordAuthentication("Publisher1", new char[] { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' }); Set credentials = new HashSet(); credentials.add(pa); connection.setCredentials(credentials); //Get the javax.xml.registry.BusinessLifeCycleManager interface, //which contains methods corresponding to UDDI publish API calls. RegistryService registryService = connection.getRegistryService(); BusinessLifeCycleManager lifeCycleManager = registryService.getBusinessLifeCycleManager(); //Create an Organization (UDDI businessEntity) with name //"Organization 1". Organization org = lifeCycleManager.createOrganization("Organization 1"); //Add the Organization to a Collection, ready to be saved in the UDDI //registry. Collection orgs = new ArrayList(); orgs.add(org); //Save the Organization in the UDDI registry. BulkResponse bulkResponse = lifeCycleManager.saveOrganizations(orgs); //Obtain the Organization Key (the UDDI businessEntity //businessKey) from the response. if (bulkResponse.getExceptions() == null) { //1 Organization was saved, so 1 key will be returned in the //response collection Collection responses = bulkResponse.getCollection(); Key organizationKey = (Key)responses.iterator().next(); System.out.println("\nOrganization Key = " + organizationKey.getId()); } } }- Ensure that the class path is set.
The class libraries of the JAXR provider for UDDI are in the com.ibm.uddi_1.0.0.jar file, in the app_server_root/plugins directory. When we use the JAXR API from a Java EE application running under WAS, all required classes are automatically on the class path. When we use the JAXR API from outside this environment, the following .jar files must be on the Java class path:
- app_server_root/lib/bootstrap.jar
- app_server_root/plugins/com.ibm.uddi_1.0.0.jar
- app_server_root/plugins/com.ibm.ws.runtime_6.1.0
- To use the JAXR provider for UDDI, first specify the name of the ConnectionFactory implementation class. Set the javax.xml.registry.ConnectionFactoryClass system property to com.ibm.xml.registry.uddi.ConnectionFactoryImpl.
If we do not set this system property, the value defaults to com.sun.xml.registry,common.ConnectionFactoryImpl, which cannot be found and causes a JAXRException exception when the ConnectionFactory.newInstance() method is called.
The JAXR provider for UDDI does not support lookup of the ConnectionFactory using JNDI.
- To specify connection-specific properties, set a java.util.Properties object on the JAXR ConnectionFactory before you obtain a connection.
The full list of these properties is in the JAXR specification. The following table lists the three most important properties, and what values they take to use the JAXR provider for UDDI to access the UDDI registry.
Property Description javax.xml.registry.queryManagerURL The URL for the Inquiry API of the UDDI registry for UDDI v2. Typically, this property is in the form: http://hostname:port/uddisoap/inquiryapi. This property is required. javax.xml.registry.lifeCycleManagerURL The URL for the Publish API of the UDDI registry for UDDI v2. Typically, this property is in the form: http://hostname:port/uddisoap/publishapi. If we do not specify this property, it defaults to the value of the javax.xml.registry.queryManagerURL property. However, the UDDI registry typically has different URLs for the Inquiry and Publish APIs, so it is advisable to specify both properties.
javax.xml.registry.authenticationMethod The method of authentication to use when authenticating with the registry. This can take one of two values, UDDI_GET_AUTHTOKEN and HTTP_BASIC. If we do not specify a value, the default value is UDDI_GET_AUTHTOKEN. See the following step for more information. The only required connection property is javax.xml.registry.queryManagerURL. However, it is advisable to set javax.xml.registry.lifeCycleManagerURL and understand the default value of javax.xml.registry.security.authenticationMethod. The other connection properties defined in the JAXR specification are optional, and their values are not specific to the UDDI registry. The JAXR provider for UDDI does not define any additional provider-specific properties.
- To determine which method the JAXR provider uses to authenticate with the UDDI registry, set the javax.xml.registry.authenticationMethod connection property.
The javax.xml.registry.authenticationMethod connection property determines which method the JAXR provider uses to authenticate with the UDDI registry. Two values of this property are supported:
- UDDI_GET_AUTHTOKEN
The JAXR provider uses the UDDI V2 get_authToken API to authenticate with the registry. The JAXR provider makes the get_authToken call automatically when the connection credentials are set. The JAXR provider saves the UDDI V2 authToken that the call returns to use on subsequent UDDI publish API calls.
- HTTP_BASIC
The JAXR provider uses HTTP basic authentication to authenticate with the registry. WAS supports HTTP basic authentication when security is enabled. The JAXR provider does not make a get_authToken call. Instead, whenever there is a UDDI API call (both Inquiry and Publish), the user name and password are sent in the HTTP headers, using HTTP basic authentication. If the UDDI registry does not require HTTP basic authentication, the credentials are ignored.
The JAXR provider for UDDI does not support the CLIENT_CERTIFICATE or MS_PASSPORT methods of authentication.
If we do not set this property, the default authentication method is UDDI_GET_AUTHTOKEN.
- To use SSL to encrypt HTTP traffic between the JAXR provider for UDDI and the UDDI registry, see Use SSL with the UDDI JAXR provider.
- To supply a custom internal taxonomy, see Create a custom internal taxonomy for the JAXR provider.
- To switch on UDDI4J logging, set the org.uddi4j.logEnabled system property to true. The JAXR provider for UDDI uses UDDI4J v2 to communicate with the UDDI registry, and UDDI4J has its own logging.
Subtopics
- Java API for XML Registries (JAXR) provider for UDDI
The Java API for XML Registries (JAXR) is a Java client API for accessing both UDDI (v2 only) and ebXML registries. It is part of the Java EE specification.- Use SSL with the UDDI JAXR provider
Use SSL to encrypt HTTP traffic between the Java API for XML Registries (JAXR) provider for UDDI and the UDDI registry.- Create a custom internal taxonomy for the JAXR provider
We can create a custom internal taxonomy and make it available to the Java API for XML Registries (JAXR) provider.- JAXR provider for UDDI internal taxonomies
The Java API for XML Registries (JAXR) provider for UDDI supplies a number of internal taxonomies.- JAXR provider logging and messages
The Java API for XML Registries (JAXR) provider for UDDI uses UDDI4J logging, commons logging, and some standard messages.