In this chapter, we will learn about web scripts and integration of WCM with external systems using web scripts. In previous chapters, you got an idea about why to use WCM, how to create web projects, and how to produce content in Alfresco WCM along with deployments to a different server. So far we discussed how we use Alfresco as a content production and delivery system and for serving the content. You may have your own application and may want to use Alfresco purely for web content management, which will just produce the content in Alfresco. But the presentation part of the application will not be handled by Alfresco. Here you can have your frontend application in any technology and you can use Alfresco WCM as the backend, which will serve the content to your application. Web script's RESTful service is one of the most easily available and widely used solutions to integrate the Alfresco WCM with any external system or application.
By the end of this chapter, you will have learned about:
In this section, you will get an overview of web scripts in WCM. We will talk about the REST architecture and web script framework in Alfresco. We will also talk about the new features introduced for web scripts in Alfresco 3. At the end of this section, you will have a very good idea about the architectural benefits of using RESTful web services, how it helps in providing solutions with the Alfresco WCM, and also how easy it is to integrate WCM with an external system.
In this section, we will discuss about the REST architecture and RESTful web services. You will also get an idea about how RESTful web services are different than our traditional SOAP-based web services and the advantages of using this approach over a traditional SOAP-based approach.
REST (Representational State Transfer) is used to describe a Web Oriented Architecture rather than a Service-Oriented Architecture. It is an architectural style following the principles referred to as "RESTful". RESTful web services are resource-oriented services. You can identify and locate resources by a Uniform Resource Identifier (URI). By making everything URL (URI)-based, you can access everything via that URL and use standard web commands such as Get
and Post
to access and update those things, something we call resources.
This URL-based update of information contrasts with a very Remote Procedure Call-like interface of SOAP. The following points give an idea about how RESTful web services differ from SOAP-based web services:
Alfresco provides a web script framework based on REST architecture, which was described in the earlier section. RESTful web scripts provide a very suitable and flexible solution to integrate Alfresco with any other application, and is usually the best solution out of all of the available options. With the help of web scripts, you can easily access the Alfresco repository and perform operations such as content searching, retrieval, manipulation, and so on with the help of services available in Alfresco, even from outside Alfresco.
A REST web script is simply a service bound to a URI and based on HTTP. So the technology that the external application is implemented on is irrelevant, that is, they are cross platform and cross language. You are not locked into any programming language or development environment.
The web script framework lets you roll your own APIs, thereby allowing you to fine-tune the remote APIs that you expose to the external application. REST provides a convenient bridge between any native application and the content management. This allows you to place controls on your enterprise content to manage it and at the same time provide uniform access for a wide variety of client applications and services, such as browser, portal, search engine, or custom application.
The advantages of using a web script for integrating external applications with Alfresco WCM are: