This chapter focused on programming and publishing RESTful services; the next chapter focuses on consuming such services, or the client side. Some of the sample clients make requests against major RESTful sites such as Amazon and Twitter, whereas others make requests against the services developed in this chapter. Once again, the goal is to illustrate, with working code, the various client-side APIs at the Java programmer’s disposal.
Four different APIs were considered in this chapter, but these APIs fall into three general groups:
HttpServlet
API, which has been around since the late 1990s, remains an excellent way to
implement RESTful services. Servlets are HTTP-aware and provide convenient filtering of requests by
HTTP verb. Programmers accustomed to implementing websites with servlets, JSP, and related scripting
languages such as JSF or Struts, should find servlets a natural and appealing way to deliver web
services as well. The servlet API is at once uncomplicated and powerful.
@WebServiceProvider
at its center, is lower level than the other
options but well suited for programmers who need to be close to the HTTP and XML metal.
This API is sufficiently rich to deliver real-world RESTful services, but the rival APIs are
more appealing in that they hide many of the details that a JAX-WS service must handle
explicitly. For SOAP-based services, the JAX-WS API is as good as any and will be the
focus in Chapters 4 and 5.