Social Media

RESTful And HATEOAS Web Services

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 –

  • Resources – Easily understood directory structure URI
  • Uniform Interface – GET, POST, PUT and DELETE
  • Messages – Can return any format – HTML, XML, plain text, …
  • Stateless – Interactions not stored

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"?>

Would become –

[sourcecode lang=”xml”] <?xml version="1.0"?>
<link rel="self" href="/customerservice/customers/1" />


About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: