Navigation Menu

ATG Rest Web Service


Creating web service -


  • Install ATG Platform Rest Web services. 
  • Define actor chain component.
  • Add rest chain in Actor chain definition file.
  • Modify /atg/rest/registory/ActorChainRegistory to add new actor-chains.
  • Call ATG Rest service using http://yourdomain.com/rest/bean/component_path

Example -

  • Define an actor-chain component. 
/atg/userprofiling/ProfileActor.properties ::
          $class=atg.service.actor.ActorChainService

          definitionFile+=ProfileActor.xml
  • Define the actor-chain definition XML file                                                                                                             
<?xml version=”1.0″ encoding=”UTF-8″?>
<actor-template>

    <actor-chain id=”update” transaction=”TX_SUPPORTS”>
<form id=”profileFormHandler-update” requires-session-confirmation=”false”>
            <input name=”firstName” value=”${param.firstName}”/>
            <input name=”lastName” value=”${param.lastName}”/>
</form>
   </actor-chain>

   <actor-chain id=”update-success” transaction=”TX_SUPPORTS”>
<output name=”response” value=”true” />
 </actor-chain>

 <actor-chain id=”update-error” transaction=”TX_SUPPORTS”>
<output name=”response” value=”false” />
 </actor-chain>

</actor-template>


  • Register the actor-chains in the ActorChainRestRegistry so that they are enabled for REST access.
/atg/rest/registry/ActorChainRestRegistry.properties ::
registeredUrls+=\

        /atg/userprofiling/ProfileActor/update,\
        /atg/userprofiling/ProfileActor/update-error,\
        /atg/userprofiling/ProfileActor/update-success  

  • Define the Java servlet bean filters.

  • Bean filters are shared across all actor calls. Use a separate filter ID if you need a specific view for a specific actor. It is best to define properties per class, as filtering will be applied to each class or interface in the class hierarchy. You can define filters for both repository items and wrapper classes for repository items.
             
    • Test this REST Service ::
            curl <command component> <cookie file> -H <content type> -d “{ <parameter> :<value>, <parameter> : <value> }” “http://<servername>:<port>/rest/model/<REST actor-chain component>/<chain ID>?<control parameter>”                                                      
    Example :

            curl -L -v -c user_cookies.txt -H “Content-Type: application/json”-d “{ “firstName” : “test” ,”lastName” : “user” }”“http://localhost:8080/rest/model/atg/userprofiling/ProfileActor/update”