Provided you can access an instance of Alfresco running on the server host
and listening on TCP port
, you can retrieve all the WSDLs for the Alfresco Web Services by pointing a browser to the URL for each service, as detailed in the following table.
Each service provides a set of operations related by a common purpose, so that you may use only the ones that you are interested in:
Service name |
Purpose |
URL |
---|---|---|
|
Manage permissions |
|
|
Execute custom actions and rules |
|
|
Manage users and groups |
|
|
Login and access session tickets |
|
|
Allows collaboration between users |
|
|
Read and write content |
|
|
Manage categories |
|
|
Manage content models |
|
|
Navigate, search, and manipulate nodes. |
|
Besides retrieving the WSDL documents online, using the URLs from the previous table, you can also find copies of the WSDLs as files in the Alfresco source tree. You can download a copy of the Alfresco source from the Subversion repository, as explained in the wiki page at http://wiki.alfresco.com/wiki/Alfresco_SVN_Development_Environment. The WSDL files can be found under root/projects/remote-api/source/wsdl
in your copy of the source tree. In this folder, you can also find all the WSDL files related to the Web Services binding of the CMIS implementation of Alfresco that will be described in Chapter 13, The Web Services Binding. Another location where you can find a copy of the WSDL documents is inside the Alfresco SDK, in the lib/remote/wsdl
folder. Downloading and installing the Alfresco SDK is the subject of the next section.
If you are developing a remote application to contact Alfresco using Java, Alfresco provides you with a precompiled Web Services client stub. The client stub allows you to invoke the Alfresco SOAP Web Services from a remote Java application, using a set of Java interfaces.
The code that makes up this client stub is available as part of the Alfresco SDK. You can download the Alfresco SDK from the same location where you can download the rest of Alfresco software. You can always browse the following web page to discover the list of files that can be downloaded for the most recent version of Alfresco Community:
http://wiki.alfresco.com/wiki/Download_Community_Edition.
Click on the Custom Installs link and look for a file to download named something like alfresco-community-sdk-3.3.zip
. Once you have unpacked it, you can load the SDK as a set of projects in the Eclipse IDE, which is explained as follows, or create a project in a different IDE, and add the libraries contained in the SDK as dependencies there.
The client stub code is contained in the alfresco-web-service-client-3.3.jar
. The interfaces contained therein can be used from your client Java application, as depicted in the following diagram. The purpose of the various interfaces and their intended usage will be the subject of the upcoming chapters.
To develop your own Web Service client application using the Web Services API of Alfresco, you need to configure your development environment with the Alfresco SDK.
Before starting to develop an application that uses the Alfresco Web Services, you need the following prerequisites:
The most common known IDEs used in the community are Eclipse and NetBeans. In this book, we will use Eclipse for all the examples and screenshots, but you can use any other IDEs.
The steps to set up your development environment using Eclipse IDE are as follows:
1. Download the latest updated version of Java JDK 1.6 from the Sun website.
2. Install Java JDK 1.6.
3. Download the latest version of the Eclipse IDE from http://eclipse.org.
4. Install Eclipse IDE.
5. Extract the Alfresco SDK package previously downloaded.
6. Import all the projects from the extracted Alfresco SDK projects from the root folder in your workspace in your IDE, in the following way:
7. Right-click on the Package Explorer, and click on Import....
8. Expand the General folder.
9. Select Existing Projects into Workspace, and press the Next button
10. Now on the Select Root Directory field, you can browse to select the root folder of the extracted Alfresco SDK.
11. Click on the Finish button to import all the projects in your Eclipse Workspace.
12. Make sure that the Java compiler compliance level is set at least to 5.0 from Windows | Preferences | Java | Compiler.
Now we have imported all the projects provided by the Alfresco SDK in to our workspace.
In order to have Alfresco source code and Java docs configured properly in Eclipse, we need to associate source code packages, related to Alfresco libraries, in the following way:
1. Right-click on the SDK AlfrescoEmbedded project.
2. Click on Properties.
3. Click on Java Build Path.
4. Click on Libraries.
5. Expand alfresco-repository-3.3.jar.
6. Select Source attachment.
7. Click on the Edit... button.
8. Click on the External File... button.
9. Browse to and select this file:
Alfresco SDK/src/alfresco-repository-src.zip
.10. Repeat all the previous steps for the following libraries:
Alfresco SDK Project
Library
Source code package
SDK AlfrescoEmbedded
alfresco-repository-3.3.jar
alfresco-repository-src.zip
SDK AlfrescoEmbedded
alfresco-core-3.3.jar
alfresco-core-src.zip
SDK AlfrescoEmbedded
alfresco-remote-api-3.3.jar
alfresco-remote-api.zip
SDK AlfrescoEmbedded
alfresco-web-client-3.3.jar
alfresco-web-client-src.zip
SDK AlfrescoRemote
alfresco-web-service-client-3.3.jar
alfresco-web-service-client-src.zip
If you want Javadocs, you also need to associate Javadocs archives:
1. Right-click on the SDK AlfrescoEmbedded project.
2. Click Properties.
3. Click on Java Build Path.
4. Click on Libraries.
5. Expand alfresco-repository-3.3.jar.
6. Select the Javadoc location.
7. Click the Edit... button.
8. Click the Javadoc in archive button.
9. Click the External file button.
10. Click the Browse... button for the Archive path field.
11. Browse to and select the
Alfresco SDK/doc/alfresco-repository-doc.zip
file.
In the same way as source code packages, repeat all the previous steps for all the following Javadoc archives:
Alfresco SDK project |
Library |
Archive package |
---|---|---|
SDK AlfrescoEmbedded |
|
|
SDK AlfrescoEmbedded |
|
|
SDK AlfrescoEmbedded |
|
|
SDK AlfrescoEmbedded |
|
|
SDK AlfrescoRemote |
|
|
The most important projects that we will use in this book are:
SDK AlfrescoEmbedded
SDK AlfrescoRemote
SDK AlfrescoEmbedded
will be used to show you how to implement a Java-backed Web Script using the Foundation Services API of Alfresco.
SDK AlfrescoRemote
will be used to show you how to implement your own Web Services client stub in your custom application. In this way, we can invoke remote calls to the repository using the Content Manipulation Language (CML).
Once you have set up the SDK in Eclipse, as explained in the previous section, you can run a sample program to verify that it is working correctly. In order to perform this test, make sure that you have installed Alfresco and that it is running. We are going to assume that it is listening for an incoming connection on the host localhost
, port 8080
.
From within Eclipse, expand the SDK FirstWebServiceClient project, and look for the source code file named FirstWebServiceClient.java
. Right-click on the file, and select Run As | Java Application. The program should start up and, after a couple of seconds, print out the following to the console window:
Content Length: 43
Now, browse the Company Home space using the Alfresco Explorer (http://localhost:8080/alfresco
) and check that a file has been created there with a name like Web Services sample
(long number here).