Packagecom.arc90.rpc.rest
Classpublic class RESTService
InheritanceRESTService Inheritance flash.events.EventDispatcher

RESTService makes fully aware HTTP service calls. Fault and Result events contain all response headers and status messages, as well as the response body.

Note: Due to Flash Player security restrictions, the RESTService class will only work under very specific conditions when delivered via the Web. However, an AIR application should not be subject to the same restrictions.



Public Properties
 PropertyDefined by
  contentType : String
Type of content for service requests.
RESTService
  headers : Object
Custom HTTP headers to be sent with the request.
RESTService
  lastRequest : Object
[read-only] The result of the last RESTService operation.
RESTService
  method : String
HTTP method for sending the request.
RESTService
  port : int
Specifies the port to be used in service calls.
RESTService
  request : Object
Object of name-value pairs used as parameters to the URL.
RESTService
  requestTimeout : int = 0
Provides access to the request timeout in seconds for sent messages.
RESTService
  resultFormat : String
Value that indicates how you want to deserialize the result returned by the HTTP call.
RESTService
  rootURL : String
The base url for service calls.
RESTService
  showBusyCursor : Boolean = false
If true, show the busy cursor while executing service calls.
RESTService
  url : String
The URL to use for the service call.
RESTService
Public Methods
 MethodDefined by
  
RESTService(rootURL:String = "", port:int = 80)
Constructor.
RESTService
  
cancel():void
Cancels the currently executing request.
RESTService
  
Clears the user credentials set by setCredentials.
RESTService
  
send():void
Executes a RESTService request.
RESTService
  
setCredentials(username:String, password:String):void
Sets credentials to be passed to the service on all service calls.
RESTService
Events
 EventSummaryDefined by
   Dispatched when a RESTService call fails.RESTService
   Dispatched when a RESTService call returns successfully.RESTService
Public Constants
 ConstantDefined by
  CONTENT_TYPE_FORM : String = "application/x-www-form-urlencoded"
[static] Indicates that the data being sent by the RESTService is encoded as application/x-www-form-urlencoded.
RESTService
  CONTENT_TYPE_MULTIPART : String = "multipart/form-data"
[static] Indicates that the data being sent by the RESTService is encoded as multipart/form-data.
RESTService
  CONTENT_TYPE_XML : String = "application/xml"
[static] Indicates that the data being sent by the RESTService is encoded as application/xml.
RESTService
  RESULT_FORMAT_BINARY : String = "binary"
[static] The result format "binary" specifiec the value returned is of type flash.utils.ByteArray.
RESTService
  RESULT_FORMAT_FLASHVARS : String = "flashvars"
[static] The result format "flashvars" specifies that the value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.
RESTService
  RESULT_FORMAT_TEXT : String = "text"
[static] The result format "text" specifies that the RESTService result text should be an unprocessed String.
RESTService
  RESULT_FORMAT_XML : String = "xml"
[static] The result format "xml" specifies that the value returned is an XML instance, which can be accessed using ECMAScript for XML (E4X) expressions.
RESTService
Property detail
contentTypeproperty
contentType:String  [read-write]

Type of content for service requests. The default is application/xml which sends requests as XML.

The default value is application/xml.

Implementation
    public function get contentType():String
    public function set contentType(value:String):void
headersproperty 
public var headers:Object

Custom HTTP headers to be sent with the request.

lastRequestproperty 
lastRequest:Object  [read-only]

The result of the last RESTService operation.

The value returned is a generic object with the following properties:

Implementation
    public function get lastRequest():Object
methodproperty 
method:String  [read-write]

HTTP method for sending the request. Permitted values are GET, POST, HEAD, OPTIONS, PUT, TRACE and DELETE. Lowercase letters are converted to uppercase letters.

The default value is GET.

Implementation
    public function get method():String
    public function set method(value:String):void
portproperty 
port:int  [read-write]

Specifies the port to be used in service calls.

If the port is not explicitly set, and the url used in the service calls utilizes the https protocol, the port will be set to 443 automatically.

The default value is 80.

Implementation
    public function get port():int
    public function set port(value:int):void
requestproperty 
public var request:Object

Object of name-value pairs used as parameters to the URL. If the contentType property is set to application/xml, it should be an XML document.

requestTimeoutproperty 
public var requestTimeout:int = 0

Provides access to the request timeout in seconds for sent messages. A value less than or equal to zero prevents request timeout.

The default value is 0.

resultFormatproperty 
resultFormat:String  [read-write]

Value that indicates how you want to deserialize the result returned by the HTTP call.

The default value is xml.

Implementation
    public function get resultFormat():String
    public function set resultFormat(value:String):void
rootURLproperty 
public var rootURL:String

The base url for service calls.

showBusyCursorproperty 
public var showBusyCursor:Boolean = false

If true, show the busy cursor while executing service calls.

The default value is false.

urlproperty 
public var url:String

The URL to use for the service call.

Constructor detail
RESTService()constructor
public function RESTService(rootURL:String = "", port:int = 80)

Constructor.

Parameters
rootURL:String (default = "") — The base url to use in all service calls.
 
port:int (default = 80) — The port to use in all service calls.
Method detail
cancel()method
public function cancel():void

Cancels the currently executing request.

clearCredentials()method 
public function clearCredentials():void

Clears the user credentials set by setCredentials.

send()method 
public function send():void

Executes a RESTService request.

setCredentials()method 
public function setCredentials(username:String, password:String):void

Sets credentials to be passed to the service on all service calls. Credentials are passed using Basic HTTP Authentication.

Parameters
username:String — The username
 
password:String — The password
Event detail
faultevent 
Event object type: com.arc90.rpc.events.FaultEvent

Dispatched when a RESTService call fails.

resultevent  
Event object type: com.arc90.rpc.events.ResultEvent

Dispatched when a RESTService call returns successfully.

Constant detail
CONTENT_TYPE_FORMconstant
public static const CONTENT_TYPE_FORM:String = "application/x-www-form-urlencoded"

Indicates that the data being sent by the RESTService is encoded as application/x-www-form-urlencoded.

CONTENT_TYPE_MULTIPARTconstant 
public static const CONTENT_TYPE_MULTIPART:String = "multipart/form-data"

Indicates that the data being sent by the RESTService is encoded as multipart/form-data.

CONTENT_TYPE_XMLconstant 
public static const CONTENT_TYPE_XML:String = "application/xml"

Indicates that the data being sent by the RESTService is encoded as application/xml.

RESULT_FORMAT_BINARYconstant 
public static const RESULT_FORMAT_BINARY:String = "binary"

The result format "binary" specifiec the value returned is of type flash.utils.ByteArray.

RESULT_FORMAT_FLASHVARSconstant 
public static const RESULT_FORMAT_FLASHVARS:String = "flashvars"

The result format "flashvars" specifies that the value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.

RESULT_FORMAT_TEXTconstant 
public static const RESULT_FORMAT_TEXT:String = "text"

The result format "text" specifies that the RESTService result text should be an unprocessed String.

RESULT_FORMAT_XMLconstant 
public static const RESULT_FORMAT_XML:String = "xml"

The result format "xml" specifies that the value returned is an XML instance, which can be accessed using ECMAScript for XML (E4X) expressions.