Reasons to use web scripts
It's now time to discover the answer to the next question—why web scripts? There are various alternate approaches available to interact with the Alfresco repository, such as CMIS, SOAP-based web services, and web scripts. Generally, web scripts are always chosen as a preferred option among developers and architects when it comes to interacting with the Alfresco repository from an external application. Let's take a look at the various reasons behind choosing a web script as an option instead of CMIS and SOAP-based web services.
In comparison with CMIS, web scripts are explained as follows:
- In general, CMIS is a generic implementation, and it basically provides a common set of services to interact with any content repository. It does not attempt to incorporate the services that expose all features of each and every content repository. It basically tries to cover a basic common set of functionalities for interacting with any content repository and provide the services to access such functionalities.
- Alfresco provides an implementation of CMIS for interacting with the Alfresco repository. Having a common set of repository functionalities exposed using CMIS implementation, it may be possible that sometimes CMIS will not do everything that you are aiming to do when working with the Alfresco repository. While with web scripts, it will be possible to do the things you are planning to implement and access the Alfresco repository as required. Hence, one of the best alternatives is to use Alfresco web scripts in this case and develop custom APIs as required, using the Alfresco web scripts.
- Another important thing to note is, with the transaction support of web scripts, it is possible to perform a set of operations together in a web script, whereas in CMIS, there is a limitation for the transaction usage. It is possible to execute each operation individually, but it is not possible to execute a set of operations together in a single transaction as possible in web scripts.
SOAP-based web services are not preferable for the following reasons:
- It takes a long time to develop them
- They depend on SOAP
- Heavier client-side requirements
- They need to maintain the resource directory
- Scalability is a challenge
- They only support XML
In comparison, web scripts have the following properties:
- There are no complex specifications
- There is no dependency on SOAP
- There is no need to maintain the resource directory
- They are more scalable as there is no need to maintain session state
- They are a lightweight implementation
- They are simple and easy to develop
- They support multiple formats
In a developer's opinion:
- They can be easily developed using any text editor
- No compilations required when using scripting language
- No need for server restarts when using scripting language
- No complex installations required
In essence:
- Web scripts are a REST-based and powerful option to interact with the Alfresco repository in comparison to the traditional SOAP-based web services and CMIS alternatives
- They provide RESTful access to the content residing in the Alfresco repository and provide uniform access to a wide range of client applications
- They are easy to develop and provide some of the most useful features such as no server restart, no compilations, no complex installations, and no need of a specific tool to develop them
- All these points make web scripts the most preferred choice among developers and architects when it comes to interacting with the Alfresco repository