如果说这篇文章可以帮助你,那么我将很荣幸,呵呵
先了解下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 Service 是一个与多种编程语言(如PHP和Java)集成的解决方案,主要关注于Adobe Flex与Web服务的交互。在本文中,我们将深入探讨Flex在Web应用程序开发中的作用,以及如何利用它与PHP和Java后端进行高效的数据...
3. **RIA对应SDK**:提供了Flex和SilverLight两种开发控件的SDK,适用于RIA(Rich Internet Applications)即富客户端应用的开发。 此外,还提到了相关的文件夹结构及文件功能说明: - **App_Code**:包含错误处理...
1. **doc 和 docx**:这是Microsoft Word的两种文档格式,允许用户在Word环境下进一步编辑和格式化报告。 2. **xls 和 xlsx**:Excel文件格式,用于保存和处理电子表格数据,便于进行数据分析和计算。 3. **text**:...
- 适用范围:适合寻求高性能解决方案的开发者。 #### II、ArcGIS Server 的 REST 接口 - **REST(Representational State Transfer)的概念**:REST是一种软件架构风格,用于设计和定义服务端和客户端之间如何...
同时,开发者还可以利用ArcGIS Server SDK进行自定义开发,创建特有的GIS解决方案。 总的来说,《ArcGIS Server开发从入门到精通》会引导你逐步掌握这个强大的GIS服务平台,无论你是初学者还是有经验的开发者,都能...
4. **JSON与XML**:这两种数据格式常用于REST API的数据交换,JSON更轻量级,适合网络传输,而XML则结构严谨,适用于复杂数据结构的表示。 5. **富互联网应用(RIA)**:RIA是指提供类似桌面应用体验的Web应用,...
Spring Cloud并没有重复造轮子,而是尽可能利用已有的解决方案来整合,最终提供了一套微服务开发工具包。 - **服务发现与注册**:Eureka、Consul等服务发现与注册中心。 - **配置中心**:Spring Cloud Config集中...