用Flex创建一个REST客户端是否可行? [英] Is it feasible to create a REST client with Flex?
问题描述
你们有一些经验类似的项目。是否可行?
这个问题很多围绕这个问题的网络讨论已经有一年多了。我现在正在通过这个研究工作,而这正是我今天所学到的。
- 他们的PHP / Groovy代码使用和期望 PUT和DELETE 但是Flex代码必须使用POST,但是将HTTP头部X-Method-Override设置为DELETE(你可以对PUT进行相同的设置)。
- Their PHP/Groovy code uses and expects PUT and DELETE.
- But the Flex code has to use POST, but sets the HTTP header X-Method-Override to DELETE (you can do the same for PUT I presume).
- Note that this is not the Proxy method discussed above.
// Flex不知道如何生成HTTP DELETE。
//幸运的是,sMash / Zero将用
//一个X-Method-Override:DELETE头解释一个HTTP POST作为DELETE。
deleteTodoHS.headers ['X-Method-Override'] ='DELETE';
这里发生了什么事? IBM Web服务器拦截并解释DELETE POST作为DELETE。
所以,我深入挖掘,发现这个(其中一个原始的SOAP家伙)。显然这是一个相当标准的行为,因为一些浏览器等不支持PUT和DELETE,并且是一个已经存在一段时间的解决方法。这里有一个片段,但有更多的讨论。 我的如果你的网络端支持这个X-Method-Override头,那么你可以使用这种方法。 Don Box的评论让我觉得它得到了很好的支持,但是我还没有证实。 另外一个问题是能够读取HTTP响应头文件。同样,从 2007年的博客文章Nathan de弗里斯,我们看到这个讨论。他跟随了他的博客文章和讨论他自己的评论: Web前端唯一的变化是更新版本的Flash玩家(当然是那些与Flex 3 beta一起提供的)现在支持HTTPStatusEvent实例的responseHeaders属性。 我希望意味着它现在是一个非问题。 I'm starting a project using a Restful architecture implemented in Java (using the new JAX-RS standard) We are planning to develop the GUI with a Flex application. I have already found some problems with this implementation using the HTTPService component (the response error codes, headers access...). Any of you guys have some experience in a similar project. Is it feasible? The problem here is that a lot of the web discussions around this issue are a year or more old. I'm working through this same research right now, and this is what I've learned today. This IBM Developer Works article from August 2008 by Jorge Rasillo and Mike Burr shows how to do a Flex front-end / RESTful back-end app (examples in PHP and Groovy). Nice article. Anyway, here's the take away: What's happening here? the IBM web server intercepts and interprets the "POST with DELETE" as a DELETE. So, I dug further and found this post and discussion with Don Box (one of the original SOAP guys). Apparently this is a fairly standard behavior since some browsers, etc. do not support PUT and DELETE, and is a work-around that has been around a while. Here's a snippet, but there's much more discussion. "If I were building a GData client, I honestly wonder why I'd bother using DELETE and PUT methods at all given that X-HTTP-Method-Override is going to work in more cases/deployments." My take away from this is that if your web side supports this X-Method-Override header, then you can use this approach. The Don Box comments make me think it's fairly well supported, but I've not confirmed that yet. Another issue arises around being able to read the HTTP response headers. Again, from a blog post in 2007 by Nathan de Vries, we see this discussed. He followed up that blog post and discussion with his own comment: "The only change on the web front is that newer versions of the Flash Player (certainly those supplied with the Flex 3 beta) now support the responseHeaders property on instances of HTTPStatusEvent." I'm hoping that means it is a non-issue now. 这篇关于用Flex创建一个REST客户端是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
lockquote
如果我正在构建一个GData客户端,我真的想知道为什么我会用DELETE和PUT方法,因为X-HTTP-Method-Override可以在更多的情况下使用/部署。
$ b
// Flex doesn't know how to generate an HTTP DELETE.
// Fortunately, sMash/Zero will interpret an HTTP POST with
// an X-Method-Override: DELETE header as a DELETE.
deleteTodoHS.headers['X-Method-Override'] = 'DELETE';