在AuthenticationUtils.startSession上挂起的Alfresco SDK代码

时间:2012-10-31 22:00:49

标签: sdk alfresco bitnami

我正在测试SDK中的代码,在bitNami Alresco 4.0.e-0服务器上调用Alfresco,其中的webapp与Alfresco位于同一个tomcat服务器上。代码在第一次调用AuthenticationUtils以获取会话时挂起。我很确定我为此提供了标准的bitNami Alfresco用户和密码。我错过了任何图书馆吗?我将大多数可用的依赖项放在我的本地maven存储库和代码编译良好。

以下是没有Alfresco许可证的SDK代码,因为我无法用它格式化代码:

package org.alfresco.sample.webservice;

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 GetStores extends SamplesBase
{
/**
 * Connect to the respository and print out the names of the available 
 * 
 * @param args
 */
public static void main(String[] args) 
    throws Exception
{
    // Start the session
    AuthenticationUtils.startSession(USERNAME, PASSWORD);

    try
    {   
        // Get the respoitory service
        RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

        // 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());
            }
        }
    }
    finally
    {
        // End the session
        AuthenticationUtils.endSession();
    }
}       
}

1 个答案:

答案 0 :(得分:1)

WebServiceFactory使用

http://localhost:8080/alfresco/api

作为默认端点。您可以通过在 alfresco 下的类路径上提供名为 webserviceclient.properties 的文件来更改端点(资源路径:alfresco / webserviceclient.properties)

属性文件必须提供名为 repository.location 的属性,该属性指定端点URL。由于您使用的是bitnam Alfresco实例,因此它可能在端口80上运行。该文件应包含以下属性条目:

repository.location=http://localhost:80/alfresco/api