Accès en webservice : Erreur de connexion

cancel
Showing results for 
Search instead for 
Did you mean: 
sebguillomon
Member II

Accès en webservice : Erreur de connexion

Bonjour,

J'essaie de me connecter en webservice à Alfresco (Entreprise 3.0 sur JBoss AS 4.2), pour cela j'ai téléchargé le Alfresco labs 3 SDK et j'utilise l'exemple de la classe "GetStores", mon serveur tourne sur le port 80, j'ai essayé en mettant comme endpoint de mon webservice mon ip, mon nom de serveur et localhost et j'ai toujours la même erreur :

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:50)
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(PlainSocketImpl.java:333)
   at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
   at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
   at java.net.Socket.connect(Socket.java:519)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   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


Le code est :


// Get the respoitory service
           WebServiceFactory.setEndpointAddress("http://10.187.4.202/alfresco/api");
            RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
           
            // Get array of stores available in the repository
            Store[] stores = repositoryService.getStores();

Quelqu'un a une idée ?

Merci bcp
4 Replies
michel
Member II

Re: Accès en webservice : Erreur de connexion

Bonjour,

C'est normal, il manque l'authentification Smiley Happy

donc le code doit ressembler à ceci:


WebServiceFactory.setEndpointAddress("http://localhost/alfresco/api");
AuthenticationUtils.startSession(USER, PASSWORD);
           
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
Store[] stores = repositoryService.getStores();
ou USER et PASSWORD sont des chaines de caractères.
donc par défaut pour l'admin c'est: USER = admin PASSWORD = admin
En espérant que ça aide

Bien à toi.

Michel.
sebguillomon
Member II

Re: Accès en webservice : Erreur de connexion

En fait si, j'avais mis juste un morceau du code dans le message, j'avais bien la ligne d'authentification.

J'ai poussé un peu plus loin mes investigations :

- Si je lance un serveur packagé par Alfresco, ça fonctionne

- Si je lance mon serveur JBoss sur lequel est déployé le war alfresco.war et que je vais à l'URL "http://localhost/alfresco/api" dans un navigateur web, il me dit que la servlet axis n'est pas disponible ….
michel
Member II

Re: Accès en webservice : Erreur de connexion

Bonjour, enfin, re Smiley Happy

Là, je pense, voir je crois, que le problème vient d'une erreur de configuration.
Je ne connais pas JBoss (j'utilise Tomcat) mais je crois qu'il faut analyser les différences dans le fichier web.xml des 2 versions que tu viens de citer.

Pour info, voici ce que j'obtiens si j'attaque directement l'url:


Axis HTTP Servlet
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'

Bien à toi.

Michel.
sebguillomon
Member II

Re: Accès en webservice : Erreur de connexion

Effectivement, ce message est le bon.

C'est le même war sur les deux serveurs mais le comportement est différent  :cry: