Create WebScript in Alfresco

In the previous post we have learned about what are webscripts and its role in Alfresco. In this post I will explain how to create a simple webscript in Alfresco. We are going to create Alfresco JavaScript based webscript. Here we are creating webscript which fetch all the document of particular type from repository and return html file with all those properties.

Step1:

Create WebScript Description file getDocs.get.desc.xml

<alfresco-config>
   <config evaluator="string-compare" condition="WebFramework">
      <web-framework>
         <defaults>
            <page-type>
               <id>login</id>
               <page-instance-id>custom-login</page-instance-id>
            </page-type>
         </defaults>
      </web-framework>
   </config>
</alfresco-config>

Step2:

Create Webscript  javascript controller file getDocs.get.js

<page>
   <template-instance>custom-login</template-instance>
   <authentication>none</authentication>
</page>

Step3:

Create Freemarker Template File getDocs.get.html.ftl

<page>
   <template-instance>custom-login</template-instance>
   <authentication>none</authentication>
</page>

 Step4:

Upload all three files under you alfresco installation under following path

CompanyHome>Data Dictionary> Web Scripts Extensions

Step5:

Restart the server hit this url

http://<host>:<port>/alfresco/service/fetchdocs

You are good to go to test above webscript you need to hit this url in your browser you will see list of documents of custom content type.

This type of webscripts is very powerful tool to expose alfresco webscript to external application. It is lightweight. It is easy to create and deploy and update. You can deploy your changes on the fly without restarting the server that is the best thing about this type of webscript.

Looking for quality Alfresco Hosting?  Look no further than Arvixe Web Hosting!

Tags: , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *


5 − 4 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>