RESTful – Representational State Transfer
RESTful Web services are an alternative to SOAP. It is designed to be simple, lightweight and fast, with the following constraint’s –
Common Operations
Consider the example in my apache cxf jax rs post. The GET, PUT and PATCH operations are idempontent. This means that the same parameters should return the same results
GET – Select – Idempotent
[sourcecode]GET /customerservice/customers/1[/sourcecode]POST – Create
[sourcecode]POST /customerservice/customers[/sourcecode]PUT – Update or Create – Idempotent
[sourcecode]PUT /customerservice/customers[/sourcecode]PATCH – Update only – Idempotent
[sourcecode]PATCH /mypath/1[/sourcecode]DELETE – Remove record
[sourcecode]DELETE /customerservice/customers/1[/sourcecode]HATEOAS – Hypermedia as the Engine of Application State
HATEOAS is a further constraint on RESTful services. It basically requires a response to return the location of the data. For example –
[sourcecode] GET customerservice/customers/1 HTTP/1.1 HTTP/1.1 200 OK<?xml version="1.0"?>
<customer>
<id>1</id>
</customer>
[/sourcecode]
Would become –
[sourcecode lang=”xml”] <?xml version="1.0"?>References
http://en.wikipedia.org/wiki/Representational_state_transfer
http://en.wikipedia.org/wiki/HATEOAS
http://docs.oracle.com/javaee/6/tutorial/doc/gijqy.html
https://www.javabullets.com/2015/01/15/apache-cxf-jax-rs/
https://github.com/spring-projects/spring-hateoas