Book Image

Learning Alfresco Web Scripts

By : Ramesh Chauhan
Book Image

Learning Alfresco Web Scripts

By: Ramesh Chauhan

Overview of this book

Table of Contents (18 chapters)
Learning Alfresco Web Scripts
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Calling web scripts from Spring-based services


If you need to invoke an Alfresco web script from Spring-based services, then you need to use RestTemplate to invoke HTTP calls. This is the most commonly used technique to execute HTTP calls from Spring-based classes. In order to do this, the following are the steps to be performed. The code snippets are also provided:

  1. Define RestTemplate in your Spring context file:

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate" />
  2. In the Spring context file, inject restTemplate in your Spring class as shown in the following example:

    <bean id="httpCommService" class="com.test.HTTPCallService">
      <property name="restTemplate" value="restTemplate" />
    </bean>
  3. In the Java class, define the setter method for restTemplate as follows:

    private RestTemplate restTemplate;
    public void setRestTemplate(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }
  4. In order to invoke a web script that has an authentication...