Version 3

    JAXR Configuration

     

    This is not a tutorial on JAXR programming. For that you can visit the Sun website for a tutorial or pick a book like "J2EE Web Services" by Richard Monson-Haefel. If you need samples, please check the testsuite in the JBoss source repository. (Task is tests-scout-jaxr)

     

    System Properties Configuration

    System properties that need to be set are as follows:

      javax.xml.registry.ConnectionFactoryClass = org.apache.ws.scout.registry.ConnectionFactoryImpl 
      jaxr.query.url = http://localhost:8080/juddi/inquiry 
      jaxr.publish.url = http://localhost:8080/juddi/publish
      juddi.proxy.transportClass = org.jboss.jaxr.juddi.transport.SaajTransport
    

     

    Important JAXR Interfaces

     

    1. RegistryService

    2. BusinessLifecycleManager

    3. BusinessQueryManager

     

      protected void getJAXREssentials() throws JAXRException
        {
            rs = connection.getRegistryService();
            blm = rs.getBusinessLifeCycleManager();
            bqm = rs.getBusinessQueryManager();
        }
    

     

    Sample Code

    1. Getting a Connection
    
    String queryurl = System.getProperty("jaxr.query.url");
            String puburl = System.getProperty("jaxr.publish.url");
    
            Properties props = new Properties();
            props.setProperty("javax.xml.registry.queryManagerURL",
                    queryurl);
    
            props.setProperty("javax.xml.registry.lifeCycleManagerURL",
                    puburl);
    
            String transportClass = System.getProperty("juddi.proxy.transportClass",                "org.jboss.jaxr.juddi.transport.SaajTransport");
            System.setProperty("juddi.proxy.transportClass", transportClass);
            try
            {
                // Create the connection, passing it the configuration properties
                factory = ConnectionFactory.newInstance();
                factory.setProperties(props);
                connection = factory.createConnection();
    
    2. Authentication with the registry
     /**
         * Does authentication with the uddi registry
         */
        protected void login()
        {
            PasswordAuthentication passwdAuth = new PasswordAuthentication(userid,
                    passwd.toCharArray());
            Set creds = new HashSet();
            creds.add(passwdAuth);
    
            try
            {
                connection.setCredentials(creds);
            } catch (JAXRException e)
            {
                e.printStackTrace();
                fail(e.getMessage());
            }
        }
    
    3. Search a Business
        public void searchBusiness(String bizname) throws JAXRException
        {
            try
            {
                // Get registry service and business query manager
                rs = connection.getRegistryService();
                bqm = rs.getBusinessQueryManager();
    
                // Define find qualifiers and name patterns
                Collection findQualifiers = new ArrayList();
                findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
                Collection namePatterns = new ArrayList();
                namePatterns.add("%" + bizname + "%");
    
                // Find based upon qualifier type and values
                BulkResponse response =
                        bqm.findOrganizations(findQualifiers,
                                namePatterns,
                                null,
                                null,
                                null,
                                null);
    
                // check how many organisation we have matched
                Collection orgs = response.getCollection();
                if (orgs == null)
                {
                    if ("true".equalsIgnoreCase(debugProp))
                        System.out.println(" -- Matched 0 orgs");
    
                } else
                {
                    if ("true".equalsIgnoreCase(debugProp))
                        System.out.println(" -- Matched " + orgs.size() + " organizations -- ");
    
                    // then step through them
                    for (Iterator orgIter = orgs.iterator(); orgIter.hasNext();)
                    {
                        Organization org = (Organization) orgIter.next();
                        if ("true".equalsIgnoreCase(debugProp))
                        {
                            System.out.println("Org name: " + getName(org));
    
                            System.out.println("Org description: " + getDescription(org));
                            System.out.println("Org key id: " + getKey(org));
                        }
    
    ....