Java Reference
In-Depth Information
JAX-RS uses JAXB for serialization, SOAP (with its ability to define schemas) makes it
much easier to generate clients that exchange complex XML documents.
Finally, you must consider the issue of packaging. If the application is deployed as an
EAR with separate web and EJB modules, there might be issues in deploying the ser-
vices. Containers might not scan the EJB module looking for RESTful web services. This
is something you should verify with your target container to make sure it behaves as ex-
pected.
There are a number of issues to consider when deciding whether to expose an EJB as a
RESTful web service. Although RESTful web services are much easier to use and are def-
initely lightweight, additional planning and thought must go into their development.
8.3.4. REST web service for ActionBazaar
The ActionBazaar application exposes some of its key services as RESTful web services.
One of the key stateless beans exposed via JAX-RS is the BidService bean that you've
seen several times throughout this topic. It contains operations for adding, removing, and
updating bids. Given the proliferation of smartphones like the iPhone, it makes sense to ex-
pose the core services in ActionBazaar via RESTful web services so that a native client can
be easily implemented on these devices. SOAP would require a significant amount of pro-
cessing and bandwidth. Although smartphones are more than capable of handling a SOAP
request, a RESTful implementation is more appropriate.
To start the development process, you'll formulate the URI for the basic operations in the
BidService :
• List the bids for a given user for a category over a date range:
/bidService/list/{userId}/{category}?startDate=x&endDate=x
• Add a new bid and accepts XML as input:
/bidService/addBid
• Retrieve a bid instance as XML or JSON:
/bidService/getBid/{bidId}
• Cancel a bid using the Bid ID:
 
Search WWH ::




Custom Search