如果说这篇文章可以帮助你,那么我将很荣幸,呵呵
先了解下REST的操作方法:
Create a new resource:
POST http://www.myserver.org/myResource (with the new contents of the resource as the POSTed payload)
Get the resource with ID=2:
GET http://www.myserver.org/myResource/2
Update the resource with ID=2
PUT http://www.myserver.org/myResource/2 (with the new contents of the resource as the PUT payload)
Delete the resource with ID=2
DELETE http://www.myserver.org/myResource/2
解决方案[/color]
[color=red]方案一:RestHttpService
下载SWC路径:
http://code.google.com/p/resthttpservice/downloads/list
将SWC添加到项目方法
查看我上一篇文章:
http://yiranwuqing.iteye.com/admin/blogs/715413
使用方法,将SWC添加到项目中后,可以在页面中直接使用
<rest:RestHttpService
id="postHttpService"
host="localhost"
port="8080"
method="{RestHttpService.METHOD_POST}"
path="/myResource"
contentType="application/xml"
result="myResultHandler(event)"
fault="myFaultHandler(event)"/>
触发方法:
postHttpService.send(<myData>This is my data</myData>);
一个具体的例子:
http://code.google.com/p/resthttpservice/wiki/Introduction
方案二:as3httpclientlib.
as3httpclientlib
下载地址:
http://code.google.com/p/as3httpclientlib/download/list
例子:
var client:HttpClient = new HttpClient();
var uri:URI = new URI("http://some.host/");
client.listener.onData = function(event:HttpDataEvent):void {
// Notified with response content in event.bytes as it streams in
};
client.listener.onComplete = function(event:HttpResponseEvent):void {
// Notified when complete (after status and data)
};
//如果是post
var json:String = "{'foo':'bar'}";
var jsonData:ByteArray = new ByteArray();
jsonData.writeUTFBytes(json);
jsonData.position = 0;
var contentType:String = "application/json";
client.post(uri, jsonData, contentType);//post
//如果是multipart
var multipart:Multipart = new Multipart([
new Part("key", objectName),
new Part("Content-Type", contentType),
new Part("AWSAccessKeyId", accessKey),
new Part("Policy", policy),
new Part("Signature", signature),
new Part("file", data, contentType, [ { name:"filename", value:objectName } ]),
new Part("submit", "Upload")
]);
client.postMultipart(uri, multipart);
//如果是Head
client.head(uri);
//如果是del
client.del(uri);
例子链接:
http://code.google.com/p/as3httpclientlib/wiki/Examples
分享到:
相关推荐
Flex构建REST
flex聊天程序客户端flex聊天程序客户端flex聊天程序客户端
JBoss作为应用服务器、MySQL作为数据存储、Hibernate完成数据访问、Spring用来构建业务层、BlazeDS作为远程服务、 Flex用来构建富客户端...!!
构建全栈式Flex、BlazeDS和Spring集成解决方案–第二部分 编写to-do list服务器端.pdf
flex是妇科客户端编程的很好变现形式。
构建全栈式Flex、BlazeDS和Spring集成解决方案
构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分 创建Maven Flex模块
flex3 客户端缓存 module 解决方案 swf文件缓存
构建全栈式Flex、BlazeDS和Spring集成解决方案!
flex的socket客户端连接java多线程socket服务端demo
构建全栈式Flex、BlazeDS和Spring集成解决方案–第三部分 整合全部应用.pdf
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第一部分_创建Maven_Flex模块
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第三部分_整合全部应用
Flex 即时聊天客户端 用了XIFF类库, 基于XAPP协议,Openfire作服务器。
Flex_rest的发布开发,希望能帮到大家
Maven构建全栈式Flex、BlazeDS和Spring集成解决方案–第二部分_编写to-do_list服务器端