Java Reference
In-Depth Information
DELETE shouldn't delete an existing bid and place a new bid. This isn't what a consumer
of the service would expect. Even if this is documented, it still violates the spirit of REST.
In addition to HTTP methods, you should also be aware of HTTP status codes. These
are defined in the RFC as well and are returned with each HTTP invocation. You've un-
doubtedly run into these codes many times. For example, you might have copied and pas-
ted an address for a website and gotten an error page with text similar to “HTTP Status
404—the requested resource isn't available.” Status codes are defined in the RFC and will
be returned for RESTful web services calls—you can think of them as analogous to a
SOAP fault. If an exception is thrown while processing a RESTful web service request, a
status code of 500 for an internal server error will most likely be returned.
Up to this point we've focused on HTTP. You might be wondering how exactly this dis-
cussion relates to RESTful web services. RESTful web services use the basic HTTP opera-
tions in combination with URLs. With a SOAP web service, you create an XML document
and then transmit it to a web service. The web service deconstructs the content of the XML
document and then figures out what code needs to be invoked. With RESTful web services,
a URL like the one examined previously is invoked using a specific HTTP method like
GET , DELETE , or PUT . There's no XML document to be processed—the method and the
URL contain everything. Parameters to the web service are encoded within the URL, just
like HTML web forms. Content, which can include Microsoft Word documents, XML doc-
uments, video clips, and so on, are included in the content of the request—that is, multipart
MIME requests that are streamed.
RESTful web services are thus a “back to the basics” approach. Invoking a RESTful web
service is as simple as invoking a URL in a web browser. Parameters are URL-encoded
and aren't embedded within an XML document. The output from a service can be any-
thing—graphics, raw text, XML, JSON, and so on. If the web service is being consumed
by an HTML 5 application, you can return the output formatted in compact JSON. Browser
JavaScript implementations process JSON an order of magnitude more efficiently than a
SOAP message.
These are the URLs for potential RESTful web services in the ActionBazaar application:
• ( DELETE ): http://actionbazaar.com/deleteBid?bidId=25
• ( PUT ): http://actionbazzar.com/placeBid?item=245&userId=4243&amount=5.66
Search WWH ::




Custom Search