Dataworks Blog

    A RESTFUL APPROACH TO WEB SERVICES

  • A RESTful Approach to Web Services

    We are going to give a quick overview of REST as a development style for web applications.

    The phrase REST (Representational State Transfer) was first coined as a pattern for developing web services in Roy Fielding’s doctorate in 2000. This paper followed on from his earlier work in the standardisation of the HTTP protocol.

    REST is a resource oriented approach to accessing web services where the resource being accessed exposes various representations of itself. Each resource has its own endpoint and is accessed directly via its URI. 

    REST is very much linked with HTTP in that it hinges on the four main HTTP commands GET, POST, PUT and DELETE.  Given that the web is built on the HTTP protocol, it is said that REST is very much in tune to how the web should work.

    When the URI is specified in the browser the resource is accessed directly with parameters passed in subsequent sections. For example http:\\testservice\1 would access a service called testservice with a parameter of 1.

    The code on the server side would be something like:

    Class testservice
    {
    @Get
    Function Book GetBookDetails(String Userparam1)
    {
                    Select * from tbBook where ISBN =  Userparam1;
                    Book book = new Book();
                    //Set properties of book
                    Return book;}
    }
    

    Generally programming languages provide routing to match the service defined in the url (testservice) to the object on the server being called. In this example they are the same.

    Generally annotations are used to flag a function as the method to provide the data back to the client. In our example GetBookDetails will be invoked on a HTTP GET request and the last item in the URI (1) will be passed as the parameter.

    A trend towards RESTful web services has been occurring over the last number of years. As shown in the chart below it has became more popular at the expense of SOAP. SOAP became very complex as the WS-* standards were added to provide features such as WS-ReliableMessaging, WS-Security, WS-Routing etc. This has led to great deal of complexity. Many of these features are unnecessary in standard web application so developers have opted to employ the simpler RESTful approach.

     

    Whereas SOAP is a defined protocol, REST is more of an architectural style. 

    Microsoft has also moved with this trend as seen with the option of plugging in a RESTful web service since SharePoint 2010. Also Microsoft Dynamics CRM 2011 allows you to access data by providing its resources with RESTful endpoints.

    Also Microsoft’s new Web API development software specialises in allowing the developer to build their server side and client side code in a RESTful manner. 

  • Back to Blogs