Java Reference
In-Depth Information
/bidService/cancel/{bidId}
A sample invocation of one of these services would look like this:
http://actionbazaar.com:8080/bidService/getBid/83749
Executing this line from a web browser would render an XML representation, gen-
erated by JAXB, of the Bid object.
To implement the RESTful web service, you annotate the local interface with the JAX-RS
annotations. This keeps the implementation clean of the JAX-RS details and also makes the
implementation much more readable. Besides being good design, the interfaces ensure that
the code doesn't become overrun with annotations. The class diagram is shown in figure
8.5 .
Figure 8.5. BidService class structure
The code for the com.actionbazaar.buslogic.BidService class is shown in
listing 8.6 . There are a total of four methods exposed via REST. This code example illus-
trates the annotations we'll cover in this chapter. After comparing the code to the URLs in
section 8.3.4 , it should be obvious how the annotations expose the methods as services. As
you can see, exposing an EJB as a RESTful web service is straightforward. In addition, the
service can be easily tested with a web browser—there's no need to generate a client.
 
Search WWH ::




Custom Search