Adobe® Flex® 4 Language Reference
Show Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
mx.rpc.http.mxml 
HTTPService 
Packagemx.rpc.http.mxml
Classpublic class HTTPService
InheritanceHTTPService Inheritance HTTPService Inheritance AbstractInvoker Inheritance EventDispatcher Inheritance Object
Implements IMXMLSupport, IMXMLObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

You use the <mx:HTTPService> tag to represent an HTTPService object in an MXML file. When you call the HTTPService object's send() method, it makes an HTTP request to the specified URL, and an HTTP response is returned. Optionally, you can pass parameters to the specified URL. When you do not go through the server-based proxy service, you can use only HTTP GET or POST methods. However, when you set the useProxy property to true and you use the server-based proxy service, you can also use the HTTP HEAD, OPTIONS, TRACE, and DELETE methods.

Note: Due to a software limitation, HTTPService does not generate user-friendly error messages when using GET.

MXML SyntaxexpandedHide MXML Syntax

The <mx:HTTPService> tag accepts the following tag attributes:

 <mx:HTTPService
 Properties
 concurrency="multiple|single|last"
 contentType="application/x-www-form-urlencoded|application/xml"
 destination="DefaultHTTP"
 id="No default."
 method="GET|POST|HEAD|OPTIONS|PUT|TRACE|DELETE"
 resultFormat="object|array|xml|e4x|flashvars|text"
 showBusyCursor="false|true"
 makeObjectsBindable="false|true"
 url="No default."
 useProxy="false|true"
 xmlEncode="No default."
 xmlDecode="No default."
 
 Events
 fault="No default."
 result="No default."
 />
 
The <mx:HTTPService> tag can have a single <mx:request> tag under which the parameters can be specified.

View the examples

See also



Public Properties
 PropertyDefined By
 InheritedchannelSet : ChannelSet
Provides access to the ChannelSet used by the service.
HTTPService
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same service.
HTTPService
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 InheritedcontentType : String
Type of content for service requests.
HTTPService
 Inheriteddestination : String
An HTTPService destination name in the services-config.xml file.
HTTPService
 Inheritedheaders : Object
Custom HTTP headers to be sent to the third party endpoint.
HTTPService
 InheritedlastResult : Object
[override] [read-only] The result of the last invocation.
HTTPService
 InheritedmakeObjectsBindable : Boolean
[override] When this value is true, anonymous objects returned are forced to bindable objects.
HTTPService
 Inheritedmethod : String
HTTP method for sending the request.
HTTPService
 InheritedoperationManager : Function
This property is set usually by framework code which wants to modify the behavior of a service invocation without modifying the way in which the service is called externally.
AbstractInvoker
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
 Inheritedrequest : Object
Object of name-value pairs used as parameters to the URL.
HTTPService
 InheritedrequestTimeout : int
Provides access to the request timeout in seconds for sent messages.
HTTPService
 InheritedresultElementType : Class
Like resultType, used to define the ActionScript class used by a given operation though this property only applies to operations which return a multi-valued result (e.g.
AbstractInvoker
 InheritedresultFormat : String
Value that indicates how you want to deserialize the result returned by the HTTP call.
HTTPService
 InheritedresultType : Class
Specifies an optional return type for the operation.
AbstractInvoker
 InheritedrootURL : String
The URL that the HTTPService object should use when computing relative URLs.
HTTPService
 InheritedserializationFilter : SerializationFilter
Provides an adapter which controls the process of converting the HTTP response body into ActionScript objects and/or turning the parameters or body into the contentType, URL, and and post body of the HTTP request.
HTTPService
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
HTTPService
 Inheritedurl : String
Location of the service.
HTTPService
 InheriteduseProxy : Boolean
Specifies whether to use the Flex proxy service.
HTTPService
 InheritedxmlDecode : Function
ActionScript function used to decode a service result from XML.
HTTPService
 InheritedxmlEncode : Function
ActionScript function used to encode a service request as XML.
HTTPService
Public Methods
 MethodDefined By
  
HTTPService(rootURL:String = null, destination:String = null)
Creates a new HTTPService.
HTTPService
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
[override] Cancels the last service invocation or an invokation with the specified ID.
HTTPService
 Inherited
clearResult(fireBindingEvent:Boolean = true):void
[override] Sets the result property of the invoker to null.
HTTPService
 Inherited
Disconnects the service's network connection.
HTTPService
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
  
Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.
HTTPService
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Logs the user out of the destination.
HTTPService
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
send(parameters:Object = null):mx.rpc:AsyncToken
Executes an HTTPService request.
HTTPService
 Inherited
setCredentials(username:String, password:String, charset:String = null):void
Sets the credentials for the destination accessed by the service.
HTTPService
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
setRemoteCredentials(remoteUsername:String, remotePassword:String, charset:String = null):void
The username and password to authenticate a user when accessing the HTTP URL.
HTTPService
 Inherited
This hook is exposed to update the lastResult property.
AbstractInvoker
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
 InheritedDispatched when an HTTPService call fails.HTTPService
 InheritedThe invoke event is fired when an HTTPService call is invoked so long as an Error is not thrown before the Channel attempts to send the message.HTTPService
 InheritedDispatched when an HTTPService call returns successfully.HTTPService
Public Constants
 ConstantDefined By
 InheritedCONTENT_TYPE_FORM : String = "application/x-www-form-urlencoded"
[static] Indicates that the data being sent by the HTTP service is encoded as application/x-www-form-urlencoded.
HTTPService
 InheritedCONTENT_TYPE_XML : String = "application/xml"
[static] Indicates that the data being sent by the HTTP service is encoded as application/xml.
HTTPService
 InheritedDEFAULT_DESTINATION_HTTP : String = "DefaultHTTP"
[static] Indicates that the HTTPService object uses the DefaultHTTP destination.
HTTPService
 InheritedDEFAULT_DESTINATION_HTTPS : String = "DefaultHTTPS"
[static] Indicates that the HTTPService object uses the DefaultHTTPS destination.
HTTPService
 InheritedERROR_DECODING : String = "Client.CouldNotDecode"
[static] Indicates that an XML formatted result could not be parsed into an XML instance or decoded into an Object.
HTTPService
 InheritedERROR_ENCODING : String = "Client.CouldNotEncode"
[static] Indicates that an input parameter could not be encoded as XML.
HTTPService
 InheritedERROR_URL_REQUIRED : String = "Client.URLRequired"
[static] Indicates that the useProxy property was set to false but a url was not provided.
HTTPService
 InheritedRESULT_FORMAT_ARRAY : String = "array"
[static] The result format "array" is similar to "object" however the value returned is always an Array such that if the result returned from result format "object" is not an Array already the item will be added as the first item to a new Array.
HTTPService
 InheritedRESULT_FORMAT_E4X : String = "e4x"
[static] The result format "e4x" specifies that the value returned is an XML instance, which can be accessed using ECMAScript for XML (E4X) expressions.
HTTPService
 InheritedRESULT_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.
HTTPService
 InheritedRESULT_FORMAT_OBJECT : String = "object"
[static] The result format "object" specifies that the value returned is XML but is parsed as a tree of ActionScript objects.
HTTPService
 InheritedRESULT_FORMAT_TEXT : String = "text"
[static] The result format "text" specifies that the HTTPService result text should be an unprocessed String.
HTTPService
 InheritedRESULT_FORMAT_XML : String = "xml"
[static] The result format "xml" specifies that results should be returned as an flash.xml.XMLNode instance pointing to the first child of the parent flash.xml.XMLDocument.
HTTPService
Constructor Detail

HTTPService

()Constructor
public function HTTPService(rootURL:String = null, destination:String = null)

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Creates a new HTTPService. This constructor is usually called by the generated code of an MXML document. You usually use the mx.rpc.http.HTTPService class to create an HTTPService in ActionScript.

Parameters
rootURL:String (default = null) — The URL the HTTPService should use when computing relative URLS.
 
destination:String (default = null) — An HTTPService destination name in the service-config.xml file.
Method Detail

initialized

()method
public function initialized(document:Object, id:String):void

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized. If you create this class in ActionScript and want it to function with validation, you must call this method and pass in the MXML document and the HTTPService's id.

Parameters

document:Object — The MXML document that created this object.
 
id:String — The identifier used by document to refer to this object. If the object is a deep property on document, id is null.

HTTPServiceExample.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the HTTPService tag. -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx"
    creationComplete="feedRequest.send();">
        
        <!-- The url property specifies the location of the requested file, 
        in this case the RSS 2.0 feed of Matt Chotin's blog. 
        As of this writing, the URL was still valid, but you should 
        check to make sure it hasn't changed. 
        You should use the latest RSS 2.0 URL listed on the right side of 
        the blog at http://www.adobe.com/go/mchotinblog. -->
        
    
    <fx:Declarations>
        <mx:HTTPService 
            id="feedRequest" 
            url="http://weblogs.macromedia.com/mchotin/index.xml" 
            useProxy="false" />
    </fx:Declarations>
        
    <mx:Panel title="HTTPService Example" height="75%" width="75%" 
        paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
            
        <mx:DataGrid id="dgPosts" height="50%" width="75%" 
            dataProvider="{feedRequest.lastResult.rss.channel.item}">
            <mx:columns>
                <mx:DataGridColumn headerText="Posts" dataField="title"/>
                <mx:DataGridColumn headerText="Date" dataField="pubDate"/>
            </mx:columns>
        </mx:DataGrid>
            
        <mx:TextArea height="50%" width="75%" htmlText="{dgPosts.selectedItem.description}"/>
    </mx:Panel>    
</s:Application>