cancel
Showing results for 
Search instead for 
Did you mean: 

connect to an Alfresco webservice [solved]

thierensbart
Champ in-the-making
Champ in-the-making
Hi,

it's my first time messing around with the Alfresco SDK and API.

I tried executing the FirstWebServiceClient after modifying the webserviceclient.properties file.

But when executing the first line of the code AuthenticationUtils.startSession("admin", "admin");,
all I get is:
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.Categories.main(Categories.java:54)
Caused by: java.net.SocketException: Connection reset
   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.SocketException: Connection reset
   at java.net.SocketInputStream.read(Unknown Source)
   at java.io.BufferedInputStream.fill(Unknown Source)
   at java.io.BufferedInputStream.read(Unknown Source)
   at org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPSender.java:583)
   at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:143)
   … 12 more

My webserviceclient.properties contains repository.location=http://192.168.10.238:8081/alfresco/api which is the correct url.
When I copy-paste it in my browser I get the standard message:
[size=200]Axis HTTP Servlet[/size]
Hi, you have reached the AXIS HTTP Servlet. Normally you would be hitting this URL with a SOAP client rather than a browser.

In case you are interested, my AXIS transport name appears to be 'http'

So what might be wrong that the code crashes while starting the session…?
7 REPLIES 7

thierensbart
Champ in-the-making
Champ in-the-making
Little sidenote:

I'm using Alfresco 3.2 but my SDK version is 2.9B.  Could this be the source of the problem?

I'm guessing it isn't…

anders_brink
Champ in-the-making
Champ in-the-making
I don't know if this applies to the programming language you are using (Java is it??), but in Powerbuilder that I am using I also had to add the service name to the location of the API.
So the same code
repository.location=http://192.168.10.238:8081/alfresco/api
would in my coding language be repository.location=http://192.168.10.238:8081/alfresco/api/AuthenticationService

I don't know if this will help you, at least I hope it won't do you any harm. Smiley Happy

/Anders

thierensbart
Champ in-the-making
Champ in-the-making
I tried that already and it gives the exact same error.

I have also updated all the wsdl files in the AlfrescoRemote project from

<wsdl:service name="AuthenticationService">
      <wsdl:documentation>Provides simple authentication capability.</wsdl:documentation>
      <wsdlSmiley Tongueort binding="auth:AuthenticationServiceSoapBinding" name="AuthenticationService">
         <wsdlsoap:address location="http://localhost:8080/alfresco/api/AuthenticationService"/>
      </wsdlSmiley Tongueort>
   </wsdl:service>
to
<wsdl:service name="AuthenticationService">
      <wsdl:documentation>Provides simple authentication capability.</wsdl:documentation>
      <wsdlSmiley Tongueort binding="auth:AuthenticationServiceSoapBinding" name="AuthenticationService">
         <wsdlsoap:address location="http://192.168.10.238:8081/alfresco/api/AuthenticationService"/>
      </wsdlSmiley Tongueort>
   </wsdl:service>

But I still get the same error.

I used WCFStorm to check if the Webservice did actually exist.

When I enter http://192.168.10.238:8081/alfresco/api/AuthenticationService, it doesn't work.
When I select the local wsdl-file for authentication authentication-service.wsdl, it works perfectly and I can provide login-credentials and receive a ticket.

So the service does exist, I'm just wondering what has to be changed/configured in order to be able to call it from my Java-class.
I just followed the FirstWebserviceClient-example and changed their 'localhost:8080' to my 192.168.10.238:8081 and yet it doesn't work…

I'm getting frustrated  Smiley Sad

mrogers
Star Contributor
Star Contributor
Yes you do need to keep your SDK and Alfresco version together.

But - are you sure you are using the correct URL,  in particular are you really running Alfresco on port 8081 rather than 8080.

thierensbart
Champ in-the-making
Champ in-the-making
I am.

The url seems right since I can connect to it from WCFStorm (a program to test services) and I can easily create a working service reference in .NET to it.

So it's just some configuration that's not correct.  Too bad I don't have a clue where.

thierensbart
Champ in-the-making
Champ in-the-making
Little update:

If I just use Axis to connect to the webservice I can connect and get a response, but it crashes while deserializing the response.

08-Oct-2009 11:33:19 org.apache.axis.client.Call invoke
SEVERE: Exception:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
   at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
   at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
   at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
   at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
   at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
   at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
   at org.apache.axis.client.Call.invoke(Call.java:2467)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.sample.webservice.Test.main(Test.java:19)
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
faultActor:
faultNode:
faultDetail:
   {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
   at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
   at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
   at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
   at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
   at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
   at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
   at org.apache.axis.client.Call.invoke(Call.java:2467)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.sample.webservice.Test.main(Test.java:19)

   {http://xml.apache.org/axis/}hostname:laptop-bart

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
   at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
   at org.apache.axis.client.Call.invoke(Call.java:2470)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.sample.webservice.Test.main(Test.java:19)
Caused by: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
   at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
   at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
   at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
   at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
   at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
   at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
   at org.apache.axis.client.Call.invoke(Call.java:2467)
   … 3 more

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi!

Based on this:
http://wiki.alfresco.com/wiki/IngresTutorial_Alfresco_Web_Service_API_for_Java#Open_and_close_sessio...

If your server host is: 192.168.10.238 and your sever port is: 8081.
Try to add this line to your code before you start the session:
WebServiceFactory.setEndpointAddress("http://192.168.10.238:8081/alfresco/api");
then authenticate:
AuthenticationUtils.startSession("admin", server_password);
Hope it helps… Smiley Wink

João Duarte