{{Obsolete}}
This functionality was removed from Alfresco in 5.0.b.
The Alfresco Flex SDK contains classes that allow full access to the capabilities of Alfresco repository via Web Scripts.
This document gives developer level instructions on how to use this API, specifically calling a Web Script from Flex and authenticating a repository user.
1. Construct an instance of WebScriptService
The class WebScriptService extends the Flex object HTTPSerivce and operates in a similar manner.
When constructing an instance of WebScriptService several parameters are available:
2. Set Success/Failure event functions
If these where not set during creation then they should be done so now. The fault event handler does not need to be specified, but if it isn't then an application error is raised with the error service.
3. Set valid ticket
If the web script you are calling required a valid ticket to be sent then a ticket should be set on thw web script service instance. This ticket will be appended to the URL in a manner that the Web Script framework will understand.
If no ticket is specified, but a valid ticket is expected then the WebScriptService instance will ask the Authentication Service for the current user's ticket.
4. Execute Web Script
Call the execute method to call the web script. Any parameters passed to this method will be appended to the executed URL as normal URL parameters.
5. Handle Success/Failure
On failure the onFailure event handler function will be called. The failure event will, apart from the usual event information, contain the related error message string.
On success the onSuccess event handler function will be called. The success event extends the standard ResultEvent class and the result property contains the result of the web script and is navigatable using the normal dot notation.
Example:
...
// Create the web script object
var url:String = 'http://myserver:8080/alfresco/service/api/login';
var webScript:WebScriptService = new WebScriptService(url, WebScriptService.GET, onLoginSuccess, onLoginFailure, false);
// Build the parameter object
var params:Object = new Object();
params.u = 'admin';
params.pw = 'admin';
// Execute the web script
webScript.execute(params);
...
public function onLoginSuccess(event:SuccessEvent):void
{
// Get the ticket from the results
this._ticket = event.result.ticket;
}
public function onLoginFailure(event:FailureEvent):void
{
// Get the error details from the failure event
var code:String = event.fault.faultCode;
var message:String = event.fault.faultString;
var details:String = event.fault.faultDetail;
...
}
The AuthenticationService is a singleton service class that provides a convenient way to authenticate a user against the Alfresco repository using the Web Script API and manage the resulting user's ticket.
public function login(userName:String, password:String):void
The login method takes the provided user credentials and authenticates then against the Alfresco repository. If the users credentials are authenticated successfully the a ticket is returned and stored and the LoginCompleteEvent event is raised.
If the login fails the onLoginFailure even is raised.
public function get ticket():String
public function get userName():String
Once a user has successfully logged in then the ticket and userName properties of the authentication service will contain the ticket and user name information for the that logged in user.
public function logout():void
The logout method invalidates the current ticket with the repository.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.