Java Reference
In-Depth Information
GET is a read-only operation. It is used to query the server for specific information. It is
both an idempotent and safe operation. Idempotent means that no matter how many times
you apply the operation, the result is always the same. The act of reading an HTML doc-
ument shouldn't change the document. Safe means that invoking a GET does not change
the state of the server at all. This means that, other than request load, the operation will
not affect the server.
PUT requests that the server store the message body sent with the request under the loca-
tion provided in the HTTP message. It is usually modeled as an insert or update. It is also
idempotent. When using PUT, the client knows the identity of the resource it is creating
or updating. It is idempotent because sending the same PUT message more than once has
no effect on the underlying service. An analogy is an MS Word document that you are
editing. No matter how many times you click the Save button, the file that stores your
document will logically be the same document.
DELETE is used to remove resources. It is idempotent as well.
POST is the only nonidempotent and unsafe operation of HTTP. Each POST method is
allowed to modify the service in a unique way. You may or may not send information
with the request. You may or may not receive information from the response.
HEAD is exactly like GET except that instead of returning a response body, it returns
only a response code and any headers associated with the request.
OPTIONS is used to request information about the communication options of the re-
source you are interested in. It allows the client to determine the capabilities of a server
and a resource without triggering any resource action or retrieval.
There are other HTTP methods (like TRACE and CONNECT), but they are unimportant
when you are designing and implementing RESTful web services.
You may be scratching your head and thinking, “How is it possible to write a distributed ser-
vice with only four to six methods?” Well…SQL only has four operations: SELECT,
INSERT, UPDATE, and DELETE. JMS and other message-oriented middleware (MOM)
really only have two logical operations: send and receive . How powerful are these tools? For
both SQL and JMS, the complexity of the interaction is confined purely to the data model.
Search WWH ::

Custom Search