Package | mx.rpc.http.mxml |
Class | public class HTTPService |
Inheritance | HTTPService ![]() ![]() ![]() ![]() |
Implements | IMXMLSupport, IMXMLObject |
<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 SyntaxThe <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.
See also
Property | Defined By | ||
---|---|---|---|
![]() | channelSet : ChannelSet
Provides access to the ChannelSet used by the service.
| HTTPService | |
concurrency : String
Value that indicates how to handle multiple calls to the same service.
| HTTPService | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
![]() | contentType : String = "application/x-www-form-urlencoded"
Type of content for service requests.
| HTTPService | |
![]() | destination : String
An HTTPService destination name in the services-config.xml file.
| HTTPService | |
![]() | headers : Object
Custom HTTP headers to be sent to the third party endpoint.
| HTTPService | |
![]() | lastResult : Object
[read-only]
The result of the last invocation.
| AbstractInvoker | |
![]() | makeObjectsBindable : Boolean
When this value is true, anonymous objects returned are forced to bindable objects.
| AbstractInvoker | |
![]() | method : String = "GET"
HTTP method for sending the request.
| HTTPService | |
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
![]() | request : Object
Object of name-value pairs used as parameters to the URL.
| HTTPService | |
![]() | requestTimeout : int
Provides access to the request timeout in seconds for sent messages.
| HTTPService | |
![]() | resultFormat : String
Value that indicates how you want to deserialize the result
returned by the HTTP call.
| HTTPService | |
![]() | rootURL : String
The URL that the HTTPService object should use when computing relative URLs.
| HTTPService | |
showBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
| HTTPService | ||
![]() | url : String
Location of the service.
| HTTPService | |
![]() | useProxy : Boolean
Specifies whether to use the Flex proxy service.
| HTTPService | |
![]() | xmlDecode : Function
ActionScript function used to decode a service result from XML.
| HTTPService | |
![]() | xmlEncode : Function
ActionScript function used to encode a service request as XML.
| HTTPService |
Method | Defined By | ||
---|---|---|---|
Creates a new HTTPService.
| HTTPService | ||
![]() |
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 | |
Cancels the most recent HTTPService request.
| HTTPService | ||
![]() |
Sets the result property of the invoker to null.
| AbstractInvoker | |
![]() |
Disconnects the service's network connection.
| HTTPService | |
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
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.
| HTTPService | ||
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Logs the user out of the destination.
| HTTPService | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
Executes an HTTPService request.
| HTTPService | ||
![]() |
Sets the credentials for the destination accessed by the service.
| HTTPService | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
The username and password to authenticate a user when accessing
the HTTP URL.
| HTTPService | |
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher |
concurrency | property |
concurrency:String
[read-write]
Value that indicates how to handle multiple calls to the same service. The default
value is multiple
. The following values are permitted:
multiple
Existing requests are not cancelled, and the developer is
responsible for ensuring the consistency of returned data by carefully
managing the event stream. This is the default value.single
Only a single request at a time is allowed on the operation;
multiple requests generate a fault.last
Making a request cancels any existing request. public function get concurrency():String
public function set concurrency(value:String):void
showBusyCursor | property |
showBusyCursor:Boolean
[read-write]
If true
, a busy cursor is displayed while a service is executing. The default
value is false
.
public function get showBusyCursor():Boolean
public function set showBusyCursor(value:Boolean):void
HTTPService | () | Constructor |
public function HTTPService(rootURL:String = null, destination:String = null)
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.
ParametersrootURL:String (default = null )
|
|
destination:String (default = null )
|
cancel | () | method |
public override function cancel(id:String = null):AsyncToken
Cancels the most recent HTTPService request.
Parameters
id:String (default = null )
|
AsyncToken |
initialized | () | method |
public function initialized(document:Object, id:String):void
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 |
|
id:String |
send | () | method |
public override function send(parameters:Object = null):AsyncToken
Executes an HTTPService request. The parameters are optional, but if specified should be an Object containing name-value pairs or an XML object depending on the contentType.
Parameters
parameters:Object (default = null )
|
AsyncToken — an AsyncToken. It will be the same object available in the result
or fault event's token property.
|
<?xml version="1.0"?> <!-- Simple example to demonstrate the HTTPService tag. --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 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. --> <mx:HTTPService id="feedRequest" url="http://weblogs.macromedia.com/mchotin/index.xml" useProxy="false" /> <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> </mx:Application>