Java Reference
In-Depth Information
providing rest services
Just as with the JAX‐WS library discussed earlier for SOAP, there exists an API for offering REST
services called JAX‐RS. Multiple implementations of this API exist, the most complete of which
is called “Jersey.” This library offers a complete package to offer and access REST services, but is
somewhat complex to set up, so it will not be discussed further.
However, based on what you've seen so far, you know that a RESTful web service is nothing more
than a structured URI scheme with a web server sending structured responses. As such, the Simple
framework discussed in the previous section can also be leveraged to build a REST service. By com-
bining what you've seen about databases, file IO, web services, and XML, you should be able to cre-
ate your own REST services without much hassle.
For now, this chapter and the wonderful world of web services is left behind you. The chapter cov-
ered a lot of topics, ranging from networking, protocols, and HTTP to SOAP, REST, JSON and
XML, and OAuth. Take some time to revisit some of the code you've seen, or feel free to explore on
your own. As always, don't be afraid to search for help online whenever you get stuck. Web tech-
nologies can get very complex, but the good thing is that there is a large community of programmers
trying to accomplish similar things, so you'll always find an answer if you encounter a problem.
In addition, this chapter—more so than others—has clearly illustrated the benefits of a rich library
ecosystem as the one found for Java. To accomplish almost all of the tasks in this chapter, you've
been using a third‐party library handling a lot of the heavy lifting for you. Setting up an OAuth
token exchange between a REST service still might not be as easy as you'd like, but think back on
the small example on TCP/IP sockets in the beginning of this chapter and imagine having to write
all other aspects of interacting with a web service on top of this. . . This illustrates another impor-
tant point when programming in Java: don't be afraid to use existing libraries. As the old saying
goes, buy the best, build the rest.
 
Search WWH ::




Custom Search