Dear Wiki user, You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.
The following page has been changed by IvanKrizsan: http://wiki.apache.org/ws/How_do_I_access_jUDDI_from_Java New page: {{{ /* * JAXRExamples.java * $Id$ */ package com.ivan.jaxr; import java.util.ArrayList; import java.util.Collection; import java.util.Properties; import javax.xml.registry.BulkResponse; import javax.xml.registry.BusinessLifeCycleManager; import javax.xml.registry.BusinessQueryManager; import javax.xml.registry.Connection; import javax.xml.registry.ConnectionFactory; import javax.xml.registry.FindQualifier; import javax.xml.registry.JAXRException; import javax.xml.registry.RegistryService; /** * This class contains JAXR examples doing the following: * - Connect to a UDDI registry. * - Query the UDDI registry for organization(s). * * Configured to use a jUDDI instance running in Tomcat on * localhost. * * Requires the following libraries: * jaxr-api.jar, jaxr-impl.jar, jaxb-api.jar, jaxb-impl.jar, * jaxb-xjc.jar, jaxb1-impl.jar, saaj-api.jar, saaj-impl.jar, * activation.jar * * @author Ivan A Krizsan */ public class JAXRExamples { /* Constant(s): */ private static final String PUBLICATION_MANAGER_URL = "http://localhost:8080/juddi//publication"; private static final String INQUIRY_MANAGER_URL = "http://localhost:8080/juddi/inquiry"; /* Instance variable(s): */ private BusinessQueryManager mBusinessQueryMgr; private BusinessLifeCycleManager mBusinessLifecycleMgr; /** * Prepares for access to the UDDI registry. */ public void init() throws JAXRException { /* * Retrieve a factory that creates JAXR connections. * A connection represents a session with a registry provider * and maintains state for the session. */ ConnectionFactory theJAXRConnectionFactory = ConnectionFactory.newInstance(); /* * Set the inquiry and publication manager URLs to be used * by the connection factory. */ Properties theUDDIConnectionProperties = new Properties(); theUDDIConnectionProperties.setProperty( "javax.xml.registry.queryManagerURL", INQUIRY_MANAGER_URL); theUDDIConnectionProperties.setProperty( "javax.xml.registry.lifeCycleManagerURL", PUBLICATION_MANAGER_URL); theJAXRConnectionFactory.setProperties(theUDDIConnectionProperties); /* Finally we can retrieve a JAXR connection. */ Connection theUDDIConnection = theJAXRConnectionFactory.createConnection(); /* * Get the RegistryService, which is used to retrieve, * among other things: * - BusinessLifeCycleManager which allows for creation and * deletion of organizations, services, associations, * classification schemes and concepts. * - BusinessQueryManager which allows for searching for the * above entity types. * - Retrieving a CapabilityProfile object from which the * capability level and JAXR version can be retrieved. */ RegistryService theRegistryService = theUDDIConnection.getRegistryService(); mBusinessQueryMgr = theRegistryService.getBusinessQueryManager(); mBusinessLifecycleMgr = theRegistryService.getBusinessLifeCycleManager(); } /** * @param args Command line arguments, not used. */ public static void main(String[] args) { try { JAXRExamples theInstance = new JAXRExamples(); theInstance.init(); theInstance.queryForOrganization(); } catch (JAXRException theException) { theException.printStackTrace(); } } /** * Queries the UDDI registry for all organizations registered. * * @throws JAXRException If error occurs querying registry. */ public void queryForOrganization() throws JAXRException { /* * Create list of query qualifiers. In this case: * - Case sensitive matching of organization names. * - Sort found organisations by name in descending order. */ ArrayList theQueryQualifiers = new ArrayList(); theQueryQualifiers.add(FindQualifier.CASE_SENSITIVE_MATCH); theQueryQualifiers.add(FindQualifier.SORT_BY_NAME_DESC); /* Create list of organization names to search for. */ ArrayList theOrganizationNames = new ArrayList(); theOrganizationNames.add("%%"); /* Use the business query manager to query for the organization(s). */ BulkResponse theQueryResponse = mBusinessQueryMgr.findOrganizations(theQueryQualifiers, theOrganizationNames, null, null, null, null); /* Retrieve list of exceptions and results from the response. */ Collection theQueryExceptions = theQueryResponse.getExceptions(); Collection theOrganizations = theQueryResponse.getCollection(); /* Output the result to the console. */ System.out.println("Listing organizations:"); for (Object theOrganization : theOrganizations) { System.out.println("An organization: " + theOrganization); } } } }}}
