Alfresco Web Services Revisited

cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Web Services Revisited

dcaruana
Active Member II
0 7 2,440

   Alfresco first introduced its Web Services for Content Management back in July 2005, almost two years ago. In those two years the software world has radically changed. Think back to July 2005. Google Maps API had only just been released, the whole Web 2.0 thing had only just started to roll, Mark Baker and company were way ahead of the curve while the rest of us believed in SOAP, and had you heard of the Arctic Monkeys? Today, it's all about mash-ups, rich applications, scripting and the network as the platform. And of course, you can't ignore the current REST Fest, now we've all caught up - could it be that SOAP slips away to be replaced with what was already there.

  

   Given this trend, ECM should rethink the way it provides Web Services.  Imagine being able to expose your enterprise content resources (folders, documents, searches, categories, versions, discussions, workflows etc) to your network with the minimum of effort; distributed resources that can be retrieved, managed, mashed by any part of your enterprise software suite. Imagine being able to build custom content services specifically for your domain and application needs without Java knowledge, tooling, compilation, stub generation or XSD.

  

   Here's an example of how such a resource (a folder) might be exposed (as an ATOM feed) via a HTTP URL:

  

Description File: folder.get.desc.xml
<webscript>
  <shortname>Folder listing</shortname>
  <url>/folder/{path}</url>
  <authentication>guest</authentication>
</webscript>

Execution Logic File: folder.get.js
model.folder = search.lookupByPath(url.extension);
if (model.folder == undefined)
{
  status.code = 404;
  status.redirect = true;
}

Response Template File: folder.get.atom.ftl
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'>
  <title>Folder: ${folder.displayPath}/${folder.name}</title>
  <updated>${xmldate(date)}</updated>
<#list folder.children as child>
  <entry>
    <title>${child.name}</title>
    <link rel='alternate' href='${child.url}'/>
    <icon>${absurl(url.context)}${child.icon16}</icon>
    <id>urn:uuid:${child.id}</id>
    <updated>${xmldate(child.properties.modified)}</updated>
    <summary>${child.properties.description!''}</summary>
    <author><name>${child.properties.creator}</name></author>
  </entry>
</#list>
</feed>

Normally, I don't post code in a blog, but this demonstrates how simple it could be to implement a content web service backed by an ECM Repository.

And this leads to Alfresco's new web services for Content Management.  With our soon-to-be-released v2.1, the installation of the above service is performed by just copying the 3 files to the Alfresco Repository Data Dictionary.  The service is then accessible via a HTTP GET e.g. to retrieve an ATOM feed for Alfresco's Company Home folder, issue...

http://<host>:<port>/alfresco/service/folder/Company%20Home

This is a simple example of an Alfresco v2.1 Web Script. An Alfresco Web Script provides a service on the web where the service may perform any function, but are particularly suited to Content Management as they're backed by all Alfresco Repository features. They're ideal for building content access & update APIs, simple UI components such as content-oriented Portlets, and integration adaptors. As an example, Alfresco's v2.1 OpenSearch has been re-hosted as a series of Web Scripts.

Each Web Script is bound to a HTTP method & custom URL Template and implemented with XML (description), Javascript and Templates. A library of URLs may be composed to provide a complete (RESTful) HTTP API. Support for multiple content-types such as ATOM, JSON (including callbacks) is provided, as well as authentication, response status codes, a simple customization model, and pluggable Web Script Runtimes.

The latest Alfresco nightly builds and SVN revisions provide the full Web Script framework.  Try it out and give us feedback before we go final.

Now, you can mash your enterprise content.
7 Comments
blog_commenter
Active Member
[...] under Play. Follow any responses to this post with its comments RSS feed. You can post a comment or trackback from yourblog. [...]
blog_commenter
Active Member
[...] Dave Caruana has posted a little article that very succinctly outlines the ease by which new “web services” (in the non-SOAP sense) can be developed using our Web Scripts. [...]
blog_commenter
Active Member
[...] Others have already commented on the potentially powerful relationship between REST and ECM. Given APP’s RESTful approach and it’s focus on publishing and editing web resources (e.g. documents, multimedia, metadata), one should expect to see Atom (format and protocol) take hold across the ECM ecosystem. [...]
blog_commenter
Active Member
It will be very helpful if there are examples along with the script listing found at alfresco/service/index/all.

That will make lessen the learning curve.
blog_commenter
Active Member
Please re-read the above as

That will lessen the learning curve.
blog_commenter
Active Member
Vineet, there are some simple samples at http://wiki.alfresco.com/wiki/Web_Scripts_Examples
blog_commenter
Active Member
hi guys...

hi guysI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well and i have start my own blog now, , thanks for your effort...