Monday, March 4, 2013

RESTful Service

Reading materials
HTTP Tutorial

There are three important things about HTTP of which you should be aware:
  • HTTP is connectionless: After a request is made, the client disconnects from the server and waits for a response. The server must re-establish the connection after it process the request.
  • HTTP is media independent: Any type of data can be sent by HTTP as long as both the client and server know how to handle the data content. How content is handled is determined by the MIME specification.
  • HTTP is stateless: This is a direct result of HTTP's being connectionless. The server and client are aware of each other only during a request. Afterwards, each forgets the other. For this reason neither the client nor the browser can retain information between different request across the web pages.

    The fundamental differences between "GET" and "POST"

    The HTML specifications technically define the difference between "GET" and "POST" so that former means that form data is to be encoded (by a browser) into a URL while the latter means that the form data is to appear within a message body. But the specifications also give the usage recommendationthat the "GET" method should be used when the form processing is "idempotent", and in those cases only. As a simplification, we might say that "GET" is basically for just getting (retrieving) datawhereas "POST" may involve anything, like storing or updating data, or ordering a product, or sending E-mail.
    Note: Remember that query strings (i.e. name/value pairs) get transferred in the URL of GET requests:
    GET /blog/?name1=value1&name2=value2 HTTP/1.1
    Host: carsonified.com
    and in the body of POST requests:
    POST /blog/ HTTP/1.1
    Host: carsonified.com
    name1=value1&name2=value2



Learn REST: A Tutorial

The letter analogy
A nice analogy for REST vs. SOAP is mailing a letter: with SOAP, you're using an envelope; with REST, it's a postcard. Postcards are easier to handle (by the receiver), waste less paper (i.e., consume less bandwidth), and have a short content. (Of course, REST requests aren't really limited in length, esp. if they use POST rather than GET.)


unlike SOAP services, REST is not bound to XML in any way. Possible formats include CSV (comma-separated values) and JSON (JavaScript Object Notation).

 JSON is more easily parsed in JavaScript; 

JAX-RS Tutorial




No comments:

Post a Comment