Java Reference
In-Depth Information
<Time>4:02pm</Time>
<Change>-6.39</Change>
<Open>187.29</Open>
<High>190.70</High>
<Low>187.01</Low>
<Volume>11255493</Volume>
<MktCap>197.9B</MktCap>
<PreviousClose>196.40</PreviousClose>
<PercentageChange>-3.25%</PercentageChange>
<AnnRange>172.19 - 211.98</AnnRange>
<Earns>14.942</Earns>
<P-E>13.14</P-E>
<Name>International Bus</Name>
</Stock>
</StockQuotes>
The idea behind REST stems from the realization that most web services just provide simple
request‐reply functionality, for which HTTP is already perfectly suited, and thus extra stan-
dards, such as SOAP, which add extra overhead and complexity, are not needed. REST just uses
HTTP as‐is, with some extra conventions added to it—one of them being that messages should
be structured to be parsed and understood by machines, and the other one being that HTTP
methods other than GET and POST (used by your browser) should be used on a structured set of
URLs, either on an URL representing a collection ( http://www.example.com/books ) or specific
resource elements ( http://www.example.com/books/B101 ). T To repeat, the four common HTTP
methods being used are:
GET : Retrieves a list of resources belonging to a collection or a formatted representation of
information on a resource element.
PUT : Replaces the entire collection with a new one, or replaces the resource element with a
new one, or creates a resource element if its identifier does not exist.
POST : Creates a new entry in a collection or creates a new entry in a resource element (less
commonly used).
DELETE : Deletes an entire collection or a resource element.
Do keep in mind, however, that unlike SOAP, REST does not have an official standard, so different
APIs may apply different conventions in terms of how they deal with these HTTP methods. Some
providers choose to use GET and POST only, or to define different URLs to deal with different actions
( /book/retrieve/B101 , /book/insert/B101 , and so on). However, since RESTful web services are
easy to understand—as they're built straight on top of HTTP—perusing the documentation given
by the service provider is in most cases enough to get going.
Accessing reSt Services Without Authentication
To get started, you will see how you can access a REST service without authentication. As before,
the examples use publicly offered services, the first of which is a simple service located at http://
www.thomas-bayer.com/sqlrest/ .
Try opening this URL in your web browser. You'll see the results shown in Figure 10-17.
 
Search WWH ::




Custom Search