You use the <mx:HTTPMultiService> tag to represent a collection of http operations. Each one has a URL, method, parameters and return type.

You can set attributes such as the URL and method on the HTTPMultiService tag to act as defaults for values set on each individual operation tag. The URL of the HTTPMultiService serves as the base url (meaning the prefix) for any relative urls set on the http operation tags. Each http operation has a send() method, which makes an HTTP request to the specified URL, and an HTTP response is returned.

You can pass parameters to the specified URL which are used to put data into the HTTP request. The contentType property specifies a mime-type which is used to determine the over-the-wire data format (such as HTTP form encoding or XML).

You can also use a serialization filter to implement a custom resultFormat such as JSON.
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: Unlike the HTTPService class, the HTTPMultiService class does not define a request property.

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

See also:

  • mx.rpc.http.HTTPService

Constructor

@:value({ destination : null, baseURL : null })new(?baseURL:String, ?destination:String)

Creates a new HTTPService. If you expect the service to send using relative URLs you may wish to specify the baseURL that will be the basis for determining the full URL (one example would be Application.application.url).

Parameters:

baseURL

The URL the HTTPService should use when computing relative URLS.

Variables

baseURL:String

The URL that the HTTPService object should use when computing relative URLs. This contains a prefix which is prepended onto any URLs when it is set. It defaults to null in which case the URL for the SWF is used to compute relative URLs.

@:flash.propertyconcurrency:String

Value that indicates how to handle multiple calls to the same operation within the service. The concurrency setting set here will be used for operations that do not specify concurrecny. Individual operations that have the concurrency setting set directly will ignore the value set here. 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.

@:value(AbstractOperation.CONTENT_TYPE_FORM)contentType:String = AbstractOperation.CONTENT_TYPE_FORM

Type of content for service requests. The default is application/x-www-form-urlencoded which sends requests like a normal HTTP POST with name-value pairs. application/xml send requests as XML.

@:value({ })headers:Dynamic = { }

Custom HTTP headers to be sent to the third party endpoint. If multiple headers need to be sent with the same name the value should be specified as an Array. These headers are sent to all operations. You can also set headers at the operation level.

@:value(true)makeObjectsBindable:Bool = true

When true, the objects returned support data binding to UI controls. That means they send PropertyChangeEvents when their property values are being changed.
This is the default value for any operations whose makeObjectsBindable property is not set explicitly.

@:value(HTTPRequestMessage.GET_METHOD)method:String = HTTPRequestMessage.GET_METHOD

HTTP method for sending the request if a method is not set explicit on the operation. Permitted values are GET, POST, HEAD, OPTIONS, PUT, TRACE and DELETE. Lowercase letters are converted to uppercase letters. The default value is GET.

@:flash.propertyoperationList:Array<AbstractOperation>

This serves as the default property for this instance so that we can define a set of operations as direct children of the HTTPMultiService tag in MXML.

@:flash.propertyresultFormat:String

Value that indicates how you want to deserialize the result returned by the HTTP call. The value for this is based on the following:

  • Whether you are returning XML or name/value pairs.
  • How you want to access the results; you can access results as an object, text, or XML.

The default value is object. The following values are permitted:

  • object The value returned is XML and is parsed as a tree of ActionScript objects. This is the default.
  • array The value returned is XML and is parsed as a tree of ActionScript objects however if the top level object is not an Array, a new Array is created and the result set as the first item. If makeObjectsBindable is true then the Array will be wrapped in an ArrayCollection.
  • xml The value returned is XML and is returned as literal XML in an ActionScript XMLnode object.
  • flashvars The value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.
  • text The value returned is text, and is left raw.
  • e4x The value returned is XML and is returned as literal XML in an ActionScript XML object, which can be accessed using ECMAScript for XML (E4X) expressions.

serializationFilter:SerializationFilter

Default serializationFilter used by all operations which do not set one explicitly

@:flash.propertyshowBusyCursor:Bool

If true, a busy cursor is displayed while a service is executing. The default value is false.

@:flash.propertyuseProxy:Bool

Specifies whether to use the Flex proxy service. The default value is false. If you do not specify true to proxy requests though the Flex server, you must ensure that the player can reach the target URL. You also cannot use destinations defined in the services-config.xml file if the useProxy property is set to false.

Methods

Inherited Variables

Defined by AbstractService

@:flash.propertychannelSet:ChannelSet

Provides access to the ChannelSet used by the service. The ChannelSet can be manually constructed and assigned, or it will be dynamically created to use the configured Channels for the destination for this service.

@:flash.propertydestination:String

The destination of the service. This value should match a destination entry in the services-config.xml file.

@:flash.propertykeepLastResult:Bool

Flag indicating whether the service's operations should keep their last call result for later access.

Setting this flag at the service level will set keepLastResult for each operation, unless explicitly set in the operation.

If set to true or not set, each operation's last call result will be accessible through its lastResult bindable property.

If set to false, each operation's last call result will be cleared after the call, and must be processed in the operation's result handler. This will allow the result object to be garbage collected, which is especially useful if the operation is only called a few times and returns a large result.

See also:

  • mx.rpc.AbstractInvoker#keepLastResult

@:flash.propertymanagers:Array<Dynamic>

The managers property stores a list of data managers which modify the behavior of this service. You can use this hook to define one or more manager components associated with this service. When this property is set, if the managers have a property called "service" that property is set to the value of this service. When this service is initialized, we also call the initialize method on any manager components.

@:flash.propertyrequestTimeout:Int

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

Inherited Methods

Defined by AbstractService

disconnect():Void

Disconnects the service's network connection and removes any pending request responders. This method does not wait for outstanding network operations to complete.

getOperation(name:String):AbstractOperation

Returns an Operation of the given name. If the Operation wasn't created beforehand, subclasses are responsible for creating it during this call. Operations are usually accessible by simply naming them after the service variable (myService.someOperation), but if your Operation name happens to match a defined method on the service (like setCredentials), you can use this method to get the Operation instead.

Parameters:

name

Name of the Operation.

Returns:

Operation that executes for this name.

initialize():Void

Called to initialize the service.

logout():Void

Logs the user out of the destination. Logging out of a destination applies to everything connected using the same ChannelSet as specified in the server configuration. For example, if you're connected over the my-rtmp channel and you log out using one of your RPC components, anything that was connected over the same ChannelSet is logged out.

Note: Adobe recommends that you use the mx.messaging.ChannelSet.logout() method rather than this method.

See also:

  • mx.messaging.ChannelSet#logout()

@:value({ charset : null })setCredentials(username:String, password:String, ?charset:String):Void

Sets the credentials for the destination accessed by the service when using Data Services on the server side. The credentials are applied to all services connected over the same ChannelSet. Note that services that use a proxy or a third-party adapter to a remote endpoint will need to setRemoteCredentials instead.

Parameters:

username

The username for the destination.

password

The password for the destination.

charset

The character set encoding to use while encoding the credentials. The default is null, which implies the legacy charset of ISO-Latin-1. The only other supported charset is "UTF-8".

@:value({ charset : null })setRemoteCredentials(remoteUsername:String, remotePassword:String, ?charset:String):Void

The username and password to be used to authenticate a user when accessing a remote, third-party endpoint such as a web service through a proxy or a remote object through a custom adapter when using Data Services on the server side.

Parameters:

remoteUsername

The username to pass to the remote endpoint

remotePassword

The password to pass to the remote endpoint

charset

The character set encoding to use while encoding the remote credentials. The default is null, which implies the legacy charset of ISO-Latin-1. The only other supported charset is "UTF-8".