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.
$class=atg.service.actor.ActorChainService
definitionFile+=ProfileActor.xml
- Define the actor-chain definition XML file
<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.
registeredUrls+=\
/atg/userprofiling/ProfileActor/update,\
/atg/userprofiling/ProfileActor/update-error,\
/atg/userprofiling/ProfileActor/update-success
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 ::
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”