Java Reference
In-Depth Information
Note Check out the “Famous Places” page ( http://cas.sdss.org/dr6/
en/tools/places/ ) at the Sloan Digital Sky Survey/SkyServer website ( ht-
tp://cas.sdss.org/ ) to obtain the right ascension and declination values for
various astronomical images.
Working with RESTful Web Services
JAX-WSalsosupportsRESTfulwebservices.Thissectionfirstshowsyouhowtocre-
ateandaccessyourownRESTfullibrarywebservice,publishthiswebservicelocally
via the default lightweight HTTP server, and access the service via a simple client. It
thenshowsyouhowtoaccessGoogle'sRESTfulChartswebservicetoobtainchartim-
ages corresponding to entered data values.
Note JavaEEprovidesJavaAPIforRESTfulWebServices(JAX-RS)tosimplify
the creation of RESTful web services via various annotations. For example, @GET is
arequestmethod(HTTPverb)designatorcorrespondingtothesimilarlynamedHTTP
verb.TheJavamethodannotatedwiththisrequestmethoddesignatorprocessesHTTP
GET requests.CheckoutChapter19“BuildingRESTfulWebServiceswithJAX-RS”
in the Java EE 6 Tutorial (see http://download.oracle.com/javaee/6/
tutorial/doc/giepu.html ) to learn about JAX-RS.
Creating and Accessing a Library Web Service
Thelibrarywebservice,whichI'venamedLibrary,consistsofthefourHTTPoperations
thathandlerequeststodeleteaspecificbook(identifiedviaitsISBN)orallbooks,get
aspecificbook(identifiedviaitsISBN)ortheISBNsofallbooks,insertanewbook,
orupdateanexistingbook. Listing11-11 presentsthewebservice's Library endpoint
class.
Listing 11-11. Library's endpoint class
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Search WWH ::




Custom Search