| Methods | Properties | Events | Examples | Frames | No Frames |
All Implemented Interfaces
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 GET or POST request to the specified URL, and an HTTP response is returned. Optionally, you can pass parameters to the specified URL.
Note: Due to a software limitation, HTTPService does not generate user-friendly error messages when using GET.
MXML Syntax
The <mx:HTTPService> tag accepts the following properties:
<mx:HTTPService
concurrency="multiple|single|last"
contentType="application/x-www-form-urlencoded|application/xml"
fault="No default."
id="No default."
method="GET|POST"
protocol="http|https"
result="No default."
resultFormat="object|xml|flashvars|text"
serviceName="No default."
showBusyCursor="false|true"
url="No default."
useProxy="true|false"
xmlEncode="No default."
xmlDecode="No default."
/>
These properties are discussed in Chapter 30, "Using Data Services" in Developing Flex Applications.
Note: To access an HTTP service over HTTPS from a Flex application that is served over HTTP, you must set theprotocol property to https. The <mx:HTTPService> tag can have a single <mx:request> tag under which the parameters can be specified.
See Also
mx.events.EventDispatcher
mx.validators.Validator
mx.managers.CursorManager
| Methods | |
| cancel(
)
:
VoidCancels all existing HTTP service calls. |
| clearResult(
fireBindingEvent:
Boolean)
:
VoidSet the result property of HTTPService to null. |
| clearUsernamePassword(
)
:
Void Removes the current username and password from subsequent requests. |
| send(
parameters:
Object)
:
Object Makes an HTTP GET or POST request to the specified URL. |
| setUsernamePassword(
username:
String, password:
String)
:
Void Sends the username and password as part of each request. |
| xmlDecode
ActionScript function used to decode a service result from XML. |
| xmlEncode
ActionScript function used to encode a service request as XML. |
| Properties | |
| concurrency:
String Value that indicates how to handle multiple calls to the same service. |
| contentType:
String Type of content for service requests. |
| method:
String HTTP method for sending the request. |
| protocol:
String(MXML only, not a runtime property) Specifies the protocol to use for service requests; the value is either http or https. |
| request:
Object Object of name-value pairs used as parameters to the URL. |
| result:
Object
[Read-Only]
Provides access to the result of the last request. |
| resultFormat:
String Value that indicates how you want to deserialize the result returned by the HTTP call. |
| serviceName:
String Named service that is specified in the server's WEB-INF/flex/flex-config.xml file. |
| showBusyCursor:
Boolean If true, a busy cursor is displayed while a service is executing. |
| url:
String Location of the service. |
| useProxy:
Boolean Whether to use the Flex proxy service. |
| Events | |
fault | ActionScript code that runs when an error has occurred. target contains a reference to the component that triggered the event. type contains the name of the event. |
result | ActionScript code that runs when a result object is available. target contains a reference to the component that triggered the event. type contains the name of the event. |
| Method Detail |
cancel(
)
:
Void
clearResult(
fireBindingEvent:
Boolean)
:
Void
Parameters
fireBindingEvent:
Boolean - true if you want anything bound to the result to update, false otherwise. Default is true
clearUsernamePassword(
)
:
Void
send(
parameters:
Object)
:
Object
Parameters
parameters:
Object - Parameters to pass to the specified URL. This parameter is optional and overrides whatever is already set in the <CODE>request</CODE> property.
Returns
HTTP call that can be used for tracking multiple requests.
setUsernamePassword(
username:
String, password:
String)
:
Void
Parameters
username:
String - Username to send.
password:
String - Pasword to send.
xmlDecode(
)
resultFormat is an object and the xmlDecode property is set, Flex uses the XML that the HTTPService returns to create an Object. If it is not defined the default XMLDecoder is used to do the work. The function referenced by the xmlDecode property must take an XMLNode object as a parameter and should return an Object. It can return any type of object, but it must return something. Returning null or undefined causes a fault.
xmlEncode(
)
contentType of a request is application/xml and the request object passed in is an Object, Flex attempts to use the function specified in the xmlEncode property to turn it into XML. If the xmlEncode property is not set, Flex uses the default XMLEncoder to turn the object graph into XML. The xmlEncode property takes an Object and should return an XMLNode. In this case, the XMLNode object can be an XML object, which is a subclass of XMLNode, or the first child of the XML object, which is what you get from an <mx:XML> tag. Returning the wrong type of object causes a fault.
| Property Detail |
concurrency:
String
contentType:
String
method:
String
protocol:
String
request:
Object
contentType property is set to application/xml, it should be an XML document.
result:
Object
[Read-Only]
resultFormat:
String
serviceName:
String
url property or the serviceName property, not both.
showBusyCursor:
Boolean
true, a busy cursor is displayed while a service is executing. The default value is false.
url:
String
<mx:HTTPService> tag contains no request parameters. Currently you can only add parameters to the URL if you set it through ActionScript, not the tag. Use either the url property or the serviceName property, not both.
useProxy:
Boolean
true. If you specify false, you must ensure that the target URL can be reached by the Flash Player. You also cannot not use named services if the useProxy property is set to false.
| Examples |
| HttpServiceExample.mxml |
|
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/15/asdocs_en/mx/servicetags/HTTPService.html