cancel
Showing results for 
Search instead for 
Did you mean: 

startSession() error: (401)Unauthorized

lurch
Champ in-the-making
Champ in-the-making
Hi,

I've recently started experimenting using AlFresco, and am trying to create a session using the web-service-client.jar from the SDK. I read the wiki and scanned some of the forums, but can't seem to find what the problem is with my code:


import org.alfresco.webservice.util.AuthenticationUtils;

public class TestSDK {
  public static void main(String[] args) {
    try {
       AuthenticationUtils.startSession("admin", "admin");
       String ticket = AuthenticationUtils.getCurrentTicket();
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       AuthenticationUtils.endSession();
     }
  }
}

This code compiled fine, but when run, I get the folowing exception:

org.alfresco.webservice.util.WebServiceException: Error starting session.
        at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:85)
        at TestSDK.main(TestSDK.java:8)
Caused by: (401)Unauthorized
        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)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:2443)
        at org.apache.axis.client.Call.invoke(Call.java:2366)
        at org.apache.axis.client.Call.invoke(Call.java:1812)
        at org.alfresco.webservice.authentication.AuthenticationServiceSoapBindingStub.startSession(AuthenticationServiceSoapBindingStub.java:187)
        at org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:70)
        … 1 more

The server is running on port 8080 on the same host as the code is run from. Can someone please point me in the right direction

Thanks in advance
1 REPLY 1

lurch
Champ in-the-making
Champ in-the-making
ok, an update.. I found that doing a wget -S to the server showed me also the 401 error, so I think it has to do with Basic HTTP authentication which has been setup for the server. Is this going to give problems for session creation or should there be no problem at all? I tried already several times to make the connection using org.apache.commons.httpclient.* stuff, but can't seem to create a session (but then again, I'm kindof new to all of this too)