cancel
Showing results for 
Search instead for 
Did you mean: 

Steps to consume web services

pal1984
Champ in-the-making
Champ in-the-making
I am trying to consume WSDL/web sevices provided by Alfresco. But Those are not getting consumed prperly. I am facing some errros out there. Can anyone please let me know what are the stpes to consume WSDL provided by alfresco? What is the WSSE headers? Is is always mandatory to use?

here is teh error I am getting while calling wsdl repository-service

Error processing WSDL document: 
WSDLException (at /wsdl:definitions/wsdl:types/schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at '/alfresco/wsdl/headers.xsd', relative to 'http://<SERVER>:8080/alfresco//wsdl/repository-service.wsdl'.: no content-type: java.net.UnknownServiceException: no content-type

Also regarding the webservices APIS, which one should be to call remotly to Alfresco?  
alfresco-web-service-client-3.2.jar or
alfresco-remote-api.jar


Thanks !!
5 REPLIES 5

amit10may
Champ in-the-making
Champ in-the-making
For webservices you need alfresco-web-service-client-3.2.jar
As far as the usage is concerned, you need to do followiing steps -

1) Set endpoint address of API - WebServiceFactory.setEndpointAddress(endPointUrl);
2)Start session - AuthenticationUtils.startSession(serverUsername, serverPassword);
3) Get required service - WebServiceFactory.getRepositoryService(); or WebServiceFactory.getContentService(); or any other - read APIs/Javadocs for this
4) Perform required APIs on the service
5) End session - AuthenticationUtils.endSession();

Regards,
Amit

_valerio_
Champ in-the-making
Champ in-the-making
1) Set endpoint address of API - WebServiceFactory.setEndpointAddress(endPointUrl);
2)Start session - AuthenticationUtils.startSession(serverUsername, serverPassword);
3) Get required service - WebServiceFactory.getRepositoryService(); or WebServiceFactory.getContentService(); or any other - read APIs/Javadocs for this
4) Perform required APIs on the service
5) End session - AuthenticationUtils.endSession();

hi amit10may
please could you  post a complete example to let me understand better the things you wrote?

I thought to do a code like this:

import org.alfresco.webservice.content.Content;
import org.alfresco.webservice.content.ContentServiceSoapBindingStub;
import org.alfresco.webservice.repository.UpdateResult;
import org.alfresco.webservice.types.*;
import org.alfresco.webservice.util.AuthenticationUtils;
import org.alfresco.webservice.util.Constants;
import org.alfresco.webservice.util.Utils;
import org.alfresco.webservice.util.WebServiceFactory;
import java.io.File;
import static java.io.File.separatorChar;
import java.io.FileInputStream; import java.io.IOException;
import java.io.InputStream;
import java.util.*;

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



????????


AuthenticationUtils.endSession();

but I don't know:
- how to fill the fields marked with ????? ?
- with what kind of extension to save the script ?  (I thought .js, isn't so?)
- where to place this file ?

could you help me, please?

openpj
Elite Collaborator
Elite Collaborator
In the Alfresco SDK, you can find a complete example of using the Web Services API.
I suggest you to take at look at it  :wink:

Hope this helps.

_valerio_
Champ in-the-making
Champ in-the-making
hi OpenPj, thanks for your reply. Smiley Very Happy
In SDK I found the example you mentioned:
-Categories
-CheckOutCheckIn
-CMLUpdates
-ContentReadAndWrite
-Query1
-Query2
-SamplesBase
but I didn't understand how to consume these examples, where to find them in my Alfresco and how to develop  and deploy one ws of mine.
I hope someone could help me, because I think the wiki pages takles these issues superficially

thanks

mwildam
Champ in-the-making
Champ in-the-making
but I didn't understand how to consume these examples, where to find them in my Alfresco and how to develop  and deploy one ws of mine.
I either did not find out how to run them (but I am on NetBeans and I know that Alfresco is built on Eclipse) - although there is an import tool, I prefered creating my own code and just used the examples as input how to do it (approximately).

I hope someone could help me, because I think the wiki pages takles these issues superficially
Indeed for a newcomer the Wiki informaion is in general quite superficial. I am still on finding out some needed things by trial and error.

BTW: Category handling is not mentioned in the samples how to deal with them.