To get started with the Java™ API for XML Registries (JAXR) provider, you can use a sample program. You also need to consider class libraries, authentication and security, internal taxonomies, and logging and messages.
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 above 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()); } } }
If you 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 Java Naming and Directory Interface (JNDI).
Property | Description |
---|---|
javax.xml.registry.queryManagerURL | The URL for the Inquiry API of the UDDI registry for UDDI Version 2. 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 Version 2. Typically, this property is in the form: http://hostname:port/uddisoap/publishapi. If you 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 you 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 that are 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.
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.
The JAXR provider uses HTTP basic authentication to authenticate with the registry. WebSphere Application Server 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.
If you do not set this property, the default authentication method is UDDI_GET_AUTHTOKEN.
In this information ...Subtopics
Related tasks
| IBM Redbooks, demos, education, and more(Index) Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience. This feature requires Internet access. Most of the following links will take you to information that is not part of the formal product documentation and is provided "as is." Some of these links go to non-IBM Web sites and are provided for your convenience only and do not in any manner serve as an endorsement by IBM of those Web sites, the material thereon, or the owner thereof. |