用于 Adobe® Flash® Platform 的 ActionScript® 3.0 参考
主页  |  隐藏包列表和类列表 |   |   |  新增内容  |  索引  |  附录  |  为什么显示为英语?
过滤条件: 正在从服务器检索数据...
正在从服务器检索数据...
mx.rpc.http.mxml 

HTTPService  - AS3 Flex

mx.rpc.http.mxml
public class HTTPService
继承HTTPService Inheritance HTTPService Inheritance AbstractInvoker Inheritance EventDispatcher Inheritance Object
实现 IMXMLSupport, IMXMLObject

语言版本: ActionScript 3.0
产品版本: Flex 3
运行时版本: Flash Player 9, AIR 1.1

在 MXML 文件中使用 <mx:HTTPService> 标签代表 HTTPService 对象。当调用 HTTPService 对象的 send() 方法时,将发出对指定 URL 的 HTTP 请求,并且返回 HTTP 响应。可以选择向指定 URL 传递参数。如果没有使用基于服务器的代理服务,则只能使用 HTTP GET 或 POST 方法。如果将 useProxy 属性设置为 true 并使用基于服务器的代理服务,则还可以使用 HTTP HEAD、OPTIONS、TRACE 和 DELETE 方法。

注意:由于软件限制,当使用 GET 时 HTTPService 不生成用户界面友好的错误消息。

MXML 语法expanded隐藏 MXML 语法

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.

查看示例

相关 API 元素



公共属性
 属性由以下参数定义
 InheritedchannelSet : ChannelSet
提供对服务使用的 ChannelSet 的访问。
HTTPService
 Inheritedconcurrency : String
指示如何处理对同一服务的多个调用的值。
HTTPService
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 InheritedcontentType : String
服务请求的内容类型。
HTTPService
 Inheriteddestination : String
services-config.xml 文件中的 HTTPService 目标名称。
HTTPService
 Inheritedheaders : Object
发送到第三方端点的自定义 HTTP 标头。
HTTPService
 InheritedlastResult : Object
[覆盖] [只读] 上次调用的结果。
HTTPService
 InheritedmakeObjectsBindable : Boolean
[覆盖] 当该置为 true 时,返回的匿名对象将强制成为可绑定的对象。
HTTPService
 Inheritedmethod : String
发送请求的 HTTP 方法。
HTTPService
 InheritedoperationManager : Function
此属性通常由框架代码设置,框架代码需要修改服务调用的行为,而不修改外部调用服务的方式。
AbstractInvoker
 Inheritedrequest : Object
用作 URL 参数的名称/值对的对象。
HTTPService
 InheritedrequestTimeout : int
提供对已发送消息的请求超时(以秒为单位)的访问。
HTTPService
 InheritedresultElementType : Class
与 resultType 类似,用于定义由给定操作使用的 ActionScript 类,但是此属性只适用于返回多值结果(例如,Array 或 ArrayCollection (IList))的操作。
AbstractInvoker
 InheritedresultFormat : String
指示如何反序列化由 HTTP 调用返回的结果的值。
HTTPService
 InheritedresultType : Class
指定操作的可选返回类型。
AbstractInvoker
 InheritedrootURL : String
HTTPService 对象在计算相对 URL 时应使用的 URL。
HTTPService
 InheritedserializationFilter : SerializationFilter
提供一个适配器,用于控制将 HTTP 响应主体转换成 ActionScript 对象和/或将参数或主体转换成 HTTP 请求的 contentType、URL 和 Post 主体的过程。
HTTPService
 InheritedshowBusyCursor : Boolean
如果为 true,在执行服务时会显示忙状态光标。
HTTPService
 Inheritedurl : String
服务的位置。
HTTPService
 InheriteduseProxy : Boolean
指定是否使用 Flex 代理服务。
HTTPService
 InheritedxmlDecode : Function
ActionScript 函数,用于解码 XML 格式的服务结果。
HTTPService
 InheritedxmlEncode : Function
ActionScript 函数,用于将服务请求按 XML 编码。
HTTPService
公共方法
 方法由以下参数定义
  
HTTPService(rootURL:String = null, destination:String = null)
创建一个新的 HTTPService。
HTTPService
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
 Inherited
[覆盖] 取消上次服务调用或具有指定 ID 的调用。
HTTPService
 Inherited
clearResult(fireBindingEvent:Boolean = true):void
[覆盖] 将 invoker 的 result 属性设置为 null。
HTTPService
 Inherited
断开服务的网络连接。
HTTPService
 Inherited
将事件调度到事件流中。
EventDispatcher
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
表示对象是否已经定义了指定的属性。
Object
  
创建实现对象且初始化在 MXML 标签上指定的所有组件属性后调用。
HTTPService
 Inherited
表示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
将用户从目标中注销。
HTTPService
 Inherited
表示指定的属性是否存在、是否可枚举。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
 Inherited
send(parameters:Object = null):mx.rpc:AsyncToken
执行 HTTPService 请求。
HTTPService
 Inherited
setCredentials(username:String, password:String, charset:String = null):void
为服务访问的目标设置凭据。
HTTPService
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
setRemoteCredentials(remoteUsername:String, remotePassword:String, charset:String = null):void
在访问 HTTP URL 时对用户进行身份验证的用户名和密码。
HTTPService
 Inherited
公开此挂钩可以更新 lastResult 属性。
AbstractInvoker
 Inherited
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。
Object
 Inherited
返回指定对象的字符串表示形式。
Object
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。
EventDispatcher
事件
 事件 摘要 由以下参数定义
 Inherited[广播事件] Flash Player 或 AIR 应用程序获得操作系统焦点并变为活动状态时将调度此事件。EventDispatcher
 Inherited[广播事件] Flash Player 或 AIR 应用程序失去操作系统焦点并变为非活动状态时将调度此事件。EventDispatcher
 Inherited当 HTTPService 调用失败时调度。HTTPService
 Inherited只要在通道尝试发送消息前没有引发错误,当调用 HTTPService 调用时将触发 invoke 事件。HTTPService
 Inherited当 HTTPService 调用成功返回时调度。HTTPService
公共常量
 常量由以下参数定义
构造函数详细信息

HTTPService

()构造函数
public function HTTPService(rootURL:String = null, destination:String = null)

语言版本: ActionScript 3.0
产品版本: Flex 3
运行时版本: Flash Player 9, AIR 1.1

创建一个新的 HTTPService。此构造函数通常由 MXML 文档生成的代码调用。通常使用 mx.rpc.http.HTTPService 类在 ActionScript 中创建 HTTPService。

参数
rootURL:String (default = null) — HTTPService 在计算相对 URL 时应使用的 URL。
 
destination:String (default = null) — service-config.xml 文件中的 HTTPService 目标名称。
方法详细信息

initialized

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

语言版本: ActionScript 3.0
产品版本: Flex 3
运行时版本: Flash Player 9, AIR 1.1

创建实现对象且初始化在 MXML 标签上指定的所有组件属性后调用。如果在 ActionScript 中创建此类并希望在其执行时使用验证,则必须调用此方法并传入 MXML 文档和 HTTPService 的 id

参数

document:Object — 创建此对象的 MXML 文档。
 
id:Stringdocument 用来引用此对象的标识符。如果此对象是文档上的深层属性,则 id 为 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>




[ X ]为什么显示为英语?
《ActionScript 3.0 参考》中的内容以英语显示

《ActionScript 3.0 参考》中的部分内容未翻译成所有语言。当某个语言元素未翻译时,将显示为英语。例如,ga.controls.HelpBox 类未翻译成任何语言。因此在简体中文版的参考中,ga.controls.HelpBox 类显示为英语。