Benefits of Using RESTful Web services for Ajax?

2020-08-04 10:09发布

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.

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?

1条回答
看我几分像从前
2楼-- · 2020-08-04 10:59

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.

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.

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.)

查看更多
登录 后发表回答