cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in SDK WebServiceSamples : Error starting session

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi all

I am attempting to run the samples of web services in SDK but I am getting the error  :

Exception in thread "main"
org.alfresco.webservice.util.WebServiceException: Error starting session.
   at
org.alfresco.webservice.util.AuthenticationUtils.startSession(AuthenticationUtils.java:94)
   at org.alfresco.sample.webservice.GetStores.main(GetStores.java:52)
Caused by: java.net.ConnectException: Connection refused: connect
   at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
   at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)
   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:79)
   … 1 more
Caused by: java.net.ConnectException: Connection refused: connect
   at java.net.PlainSocketImpl.socketConnect(Native Method)
   at java.net.PlainSocketImpl.doConnect(Unknown Source)
   at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
   at java.net.PlainSocketImpl.connect(Unknown Source)
   at java.net.SocksSocketImpl.connect(Unknown Source)
   at java.net.Socket.connect(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at
org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
   at
org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
   at
org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
   at
org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
   at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
   … 12 more




i make the right port of alfresco in webserviceclient.properties but…..
what is the problem ?

Thanks & Regards
Nishant
6 REPLIES 6

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

I solved the problem.

We just need to insert the following piece of code before trying login to alfresco.

WebServiceFactory.setEndpointAddress("http://10.232.10.171:8080/alfresco/api");

The url is the url in which the alfresco webservice api works.

Regards
Nishant

odi
Champ in-the-making
Champ in-the-making
Where actually I have to add this code
"WebServiceFactory.setEndpointAddress("http://10.232.10.171:8080/alfresco/api"); "

Regards

sselvan
Champ in-the-making
Champ in-the-making
Thanks a lot Nishant. You definitely saved me sometime.

youssef
Champ in-the-making
Champ in-the-making
hi I would like add

AuthenticationUtils
WebServiceFactory.setEndpointAddress("http://10.232.10.171:8080/alfresco/api");
before trying login to alfresco.

but I can't editing AuthenticationUtils.java because it is in mode read only
anyone help me plz
tanks

kaynezhang
World-Class Innovator
World-Class Innovator
Why would you like to edit AuthenticationUtils.java ,you don't need to edit.
just call

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

Then you can do whatever you want to

divyank
Champ in-the-making
Champ in-the-making
Iam getting the same error session is not getting started even after including WebServiceFactory.setEndpointAddress("http://192.168.1.90:8484/alfresco/api"); Iam using the code below to download a file

public String webService(String dir, String fileName)   throws Exception

{

String downloadURL = null;
try {

System.out.println("dir ::" + dir);

System.out.println("fileName ::" + fileName);

// Start the session
   WebServiceFactory.setEndpointAddress("http://127.0.0.1:8080/alfresco/api");
AuthenticationUtils.startSession("admin", "Password123");

String ticket = AuthenticationUtils.getTicket();

// Create a reference to the parent where we want to create content

Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

// Reference reference = new Reference(storeRef, null,

// "/app:company_home/cmsmileyCMCOE/cm:COE1/*[@cm:name=\"" +

// "eProfilerPPT" + "\"]");

// Create a new Reference to the node you want (variable path here).

String path = dir + "*[@cm:name=\"" + fileName + "\"]";

Reference reference = new Reference(storeRef, null, path);

ContentServiceSoapBindingStub contentService = WebServiceFactory

.getContentService();

// Read the content from the respository

Content[] readResult = contentService.read(new Predicate(

new Reference[] { reference }, storeRef, null),

Constants.PROP_CONTENT);

Content contentRef = readResult[0];

// Get the ticket URL as above and the downloadURL here points to

// the url where the content is present.

System.out.println("contentRef.getUrl() : " + contentRef.getUrl());

String ticketURL = "?ticket=" + ticket;

downloadURL = contentRef.getUrl() + ticketURL;

System.out.println("downloadURL in webService(): " + downloadURL);

} catch (Throwable e) {

System.out.println(e.toString());

} finally {

// End the session

// AuthenticationUtils.endSession();

}

return downloadURL;

}

What can be my directory if the file to be downloaded is in a site created by me called "mysite" document library in alfresco share

Iam using Alfresco community edition 5.0.d