RESTful web service tutorial

In this post, we will see RESTful web service introduction.

Web service Tutorial Content:

REST is an architectural style which was brought in by Roy Fielding in 2000 in his doctoral thesis.In the web services terms, REpresentational State Transfer (REST) is  a stateless client-server architecture in which the web services are viewed as resources and can be identified by their URIs. Web service clients that want to use these resources access via globally defined set of remote methods that describe the action to be performed on the resource.

It consists of two components REST server which provides access to the resources and a REST client which accesses and modify the REST resources.

In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.REST isn’t protocol specific, but when people talk about REST they usually mean REST over HTTP.
The response from server is considered as the representation of the resources. This representation can be generated from one resource or more number of resources.

REST allows that resources have different representations, e.g.xml, json etc. The rest client can ask for specific representation via the HTTP protocol.

HTTP methods :

RESTful web services use HTTP protocol methods for the operations they perform.Methods are:

  • GET:It defines a reading access of the resource without side-effects.This operation is idempotent i.e.they can be applied multiple times without changing the result
  • PUT :  It is generally used for updating resouce.It must also be idempotent.
  • DELETE : It removes the resources. The operations are idempotent i.e. they can get repeated without leading to different results.
  • POST :It is used for creating a new resource. It is not idempotent.
Idempotent means result of multiple successful request will not change state of resource after initial application
For example :
Delete is idempotent method because when you first time use delete, it will delete the resource (initial application) but after that, all other request will have no result because resource is already deleted.
Post is not idempotent method because when you use post to create resource , it will keep creating resource for each new request, so result of multiple successful request will not be same.

Features of RESTful web services:

Resource identification through URI:Resources are identified by their URIs (typically links on internet). So, a client can directly access a RESTful Web Services using the URIs of the resources (same as you put a website address in the browser’s address bar and get some representation as response).

Uniform interface: Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE.

Client-Server: A clear separation concerns is the reason behind this constraint. Separating concerns between the Client and Server helps improve portability in the Client and Scalability of the server components.

Stateless: each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server.

Cache: to improve network efficiency responses must be capable of being labeled as cacheable or non-cacheable.

Named resources – the system is comprised of resources which are named using a URL.

Interconnected resource representations – the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another.

Layered components – intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc.

Self-descriptive messages: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others.

You can also check Restful interview questions with answers for beginners and experienced


import_contacts

You may also like:

Related Posts

  • 04 August

    Spring Restful web services xml example

    Table of ContentsWeb service Tutorial Content:Spring application configuration:Create bean classCreate controllerRun the application This post is in continuation with web service tutorial (Part -10). In this tutorial,we are going to see Spring Restful web services xml example. Web service Tutorial Content: Introduction to web services Web services interview questions SOAP web service introduction RESTful web service […]

  • 26 June

    Difference between SOAP and REST web services in java

    We have already seen SOAP web services and RESTful web services in detail before. In this post, we are going to see differences between SOAP and REST web services. SOAP vs REST web services Parameter SOAP REST Acronym SOAP stands for simple object access protocol REST stands for REpresentational State Transfer Protocol vs Architectural style […]

  • Web services interview questions
    24 June

    Top 20 Web services interview questions

    Web services interview questions are most asked questions if you are applying for software developer role. In this post, we will see multiple web services interview questions. 1. What are web services? Web services are ways of communication between two application over network. It allows you to expose business logic using API. For example: Lets […]

  • Restful web services interview questions
    22 June

    Restful web services interview questions

    Restful web services are very popular now a days because it is very simple to implement and less time consuming. In this post, we are going to see restful web services interview questions with answers. 1. What is REST? REST is an architectural style which was brought in by Roy Fielding in 2000 in his […]

  • 15 April

    Spring Restful web services CRUD example

    Table of ContentsWeb service Tutorial Content:Source code:Maven dependenciesSpring application configuration:Create bean classCreate ControllerCreate Service classRun the applicationGet methodPost methodPut MethodDelete methodProject structure: In this post, we are going see Spring Restful web services CRUD example. Web service Tutorial Content: Introduction to web services Web services interview questions SOAP web service introduction RESTful web service introduction Difference […]

  • 29 March

    RESTful web services JAXRS CRUD example using jersey

    Table of ContentsSource code:Maven dependenciesApplication configuration:Create bean classCreate ControllerCreate Service classRun the applicationPost methodPut Method This post is in continuation with web service tutorial (Part -8). Introduction to web services Web services interview questions SOAP web service introduction RESTful web service introduction Difference between SOAP and REST web services SOAP web service example in java […]

Comments

  1. Hi
    i want to write a web service to query PNG images from a database and convert them to pdf and upload back. could you please give me some insight on as to how to get this done? im not having any experience with web services
    thanks!

  2. Are you sure that specification POST and PUT methods is not mixed up? PUT – create or modified, when POST – for only create resource.

    1. they are. Technically POST creates a new resource and PUT updates an existing resource. In practice there is not that much difference. The real killer is NEVER allow a GET to alter or create resources.

  3. Because of your blog I love to learn java
    Easy and explanation with detailed examples. Awesome. You should be blessing for more people.
    God bless you

  4. it is a very nice tutorial because i dont get a good example for webservice in other websites but this site only i got a result .thanks. but In RESTSERVICE i got requested resource error

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.