Alfresco 5.0:AuthenticationUtils.startSession生成404

时间:2014-09-03 17:17:28

标签: java web-services alfresco alfresco-share cmis

我正在开发一个旧项目,由于部署新版本的时间很短,我无法使用CMIS迁移内容上传,因此,我需要使用旧的WebServiceFactory代码将二进制文件创建到Alfresco中。

但是,随着新版Alfresco(5.0.a)的发布,我无法使用以下方式获得授权:

WebServiceFactory.setEndpointAddress("http://localhost:8080/alfresco/api");             
AuthenticationUtils.startSession(userName, password);

这是我得到的错误:

Caused by: (404)Not Found
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

有任何线索吗?你知道从Java类创建文件夹和更新二进制文件是否真的(真的很快)?

感谢,
安德莉亚

2 个答案:

答案 0 :(得分:2)

this code获取File Loader示例,将pom.xml编辑为所有内容的最新版本,将其指向您的服务器,运行,享受。

答案 1 :(得分:1)

问题只与第一个会话的开始有关,在我们的例子中,因为WebServiceFactory默认尝试加载文件“alfresco / webserviceclient.properties”。

我们已解决了此解决方法的问题:

public static void startSession(String endpoint, String username, String password)
                throws Exception {

    try {
        if (_log.isDebugEnabled()) {
            _log.debug("Connecting to: " + endpoint);
        }
        /** fix for http 404 error during start first session
         *  needs to init {@link WebServiceFactory#loadedProperties} field to true and nothing else
         */
        WebServiceFactory.getEndpointAddress();
        /** fix for http 404 error during start first session*/

        WebServiceFactory.setEndpointAddress(endpoint);

        AuthenticationUtils.startSession(username, password);
        if (_log.isDebugEnabled()) {
            _log.debug("Start session with ticket: " + AuthenticationUtils.getTicket());
        }

    }
    catch (Exception e) {
        _log.error("Can not initiate session with Alfresco server.");
        throw e;
    }
}