AnsweredAssumed Answered

Java webservice timeout

Question asked by pinipints on Nov 25, 2008
Latest reply on Apr 23, 2012 by nareshthota
Hi,

I am using the sample code to connect to the webservice, but whenever i try to run the program it gives me a connection timeout. I checked the AuthenticationUtils.startSession which internally calls the WebserviceFactory.getEndpointAddress() method. It reads from a property file alfresco/webserviceclient.properties for the url. However, if not found it uses the default address: http://localhost:8080/alfresco/api

When i copy paste the same URL in browser it shows the AXIS page but a timeout when running from java code. Please help.

Thanks
Punit

package com.alfresco.trial;

import org.alfresco.webservice.authentication.AuthenticationFault;
import org.alfresco.webservice.repository.RepositoryServiceSoapBindingStub;
import org.alfresco.webservice.types.Store;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.WebServiceFactory;

public class AlfrescoSpace {

   /**
    * @param args
    * @throws AuthenticationFault
    */
   public static void main(String[] args) {
      
       try
           {
             AuthenticationUtils.startSession("admin", "admin");
               // Get the respoitory service
               RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService("http://localhost:8080/alfresco/");
              
               // Get array of stores available in the repository
               Store[] stores = repositoryService.getStores();
               if (stores == null)
               {
                   // NOTE: empty array are returned as a null object, this is a issue with the generated web service code.
                   System.out.println("There are no stores avilable in the repository.");
               }
               else
               {
                   // Output the names of all the stores available in the repository
                   System.out.println("The following stores are available in the repository:");
                   for (Store store : stores)
                   {
                       System.out.println(store.getScheme() + "://" + store.getAddress());
                   }
               }
               AuthenticationUtils.endSession();
           } catch(Exception ex) {
              ex.printStackTrace();
           }
   }

}

Outcomes