使用RESTful Web服务为Ajax的好处? [英] Benefits of Using RESTful Web services for Ajax?

查看:208
本文介绍了使用RESTful Web服务为Ajax的好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

纠正我,如果我错了,但似乎很多人都在使用REST Web服务提供数据给阿贾克斯。但是,一个普通Servlet或PHP页面可以很容易地将这些信息提供给Ajax应用程序。所以,我没有看到创建Web服务,甚至是一个RESTful一体,提供数据,以Ajax调用的利益。

Correct me if I'm wrong, but it seems that many people are using RESTful web services to provide data to Ajax. However, a normal Servlet or PHP page can easily provide that information to Ajax applications. So, I don't see the benefit of creating web service, even a RESTful one, to provide data to Ajax calls.

所以,我的问题是:什么是使用RESTful Web服务,而不是使用一个简单的servlet或PHP页面,以提供响应Ajax应用程序的好处

So, my question is: what is the benefit of using a RESTful web service, rather than using a simple Servlet or PHP page to provide response to a Ajax application?

推荐答案

的RESTful 使用HTTP协议和HTTP方法调用的Web服务。 REST Web服务没有任何特殊的协议,如大(SOAP)的Web服务有。

RESTful Web Services are using the HTTP protocol and HTTP Methods for invocation. RESTful Web Services doesn't have any special protocol like "big" (SOAP) Web Services have.

因此​​,Servlet的可用于创建REST Web服务,以及。其实这件事,如果你创建一个简单的Servlet与的doGet( - )方法,你刚刚创建服务RESTful Web服务 GET HTTP方法调用。
同样是与你的简单的PHP页面。

Therefore, Servlets can be used to create RESTful Web Services as well. In the matter of fact, if you create a simple Servlet with doGet(-) method, you've just created a RESTful Web Service serving GET HTTP Method invocations.
The same is with your simple PHP page.

如果你指的是REST Web服务作为一种即JAX-RS实现,比你买一个灵活和易于开发的( @Produces @Consumes @FormParam ,多个 @ GET 方法等。)

If you're referring to RESTful Web Services as an i.e. JAX-RS implementation, than it buys you a flexibility and ease of development (@Produces, @Consumes, @FormParam, multiple @GET methods etc.)

这篇关于使用RESTful Web服务为Ajax的好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆