Tuesday, June 6, 2017

Web Services Introduction

Web Service definition

  • A web service is a distributed software whose components can be deployed and executed on distinct devices.
  • A web service consists of a service (a.k.a. producer) and a client (a.k.a. consumer or requester).

Web Service over HTTP

  • A web service is an application typically running over HTTP.
  • A web service over HTTP is a web service that uses the HTTP as transport, HTTP messages are infrastructure.

Web Service architecture

  • The architecture of a simple web service is a client and a server.
  • The architecture of a complicated web service have many clients and a service composed of other services.
    • for example, an e-commerce service can be composed of multiple code components (each hosted on a separate web server) and any combination of PCs, tablets, mobile phones and other networked devices may host programs that make requests to the service.

Web services come in two flavors: SAOP-based and REST-style.

  • SOAP is an XML dialect that specifies the structure of XML documents that count as SOAP envelopes
  • A REST-style service is one that treats HTTP not only as a transport infrastructure but also as a set of guidelines for making service requests and responses.

Web service features

  • Web service major attractiveness is interoperability: clients and services can interact despite differences in programming languages, operating systems and hardware platforms.
  • XML and JSON are web service data interchange formats that provide an intermediary level and handle the differences in data types between different programming languages.


REST definition

  • REST (REpresentational State Transfer) is an acronym created by Roy Fielding to describe the principles for building software systems that are known as REST-style or RESTful web service..
  • REST is an software architecture style for hypermedia systems.
    • Hypermedia systems are systems where text, pictures, audio, video and other media are stored in network hosts and connected through hyperlinks.
    • the web is the example of hypermedia system

RESTful Systems and HTTP

  • HTTP is both a transport protocol and a messaging system
  • HTTP requests and HTTP responses are the messages
  • HTTP payloads can be typed using the MIME type system
  • HTTP response status codes notify the requester about whether the request was successful or not.

REST centers around the concept of resource.

  • A resource is something accessible through HTTP because the resource has an URI (Uniform Resource Identifier). The URL (Uniform Resource Location) is an URI subtype.
  • In practice, a resource is a piece of information accessible on the web that may have hyperlinks to it. Hyperlinks use URIs.
    • For example, the Pink Floyd rock band is a resource.
  • Resources may have one or more representations. Those representations in the web are MIME typed.
    • For example, the page on wikipedia about Pink Floyd has text/html MIME type.
  • Resources have a state that may change over time and resource’s representations capture this state.
    • For example, Pink Floyd recorded many albums during their career. The Pink Floyd’s discography make up Pink Floyd resource’s representation.

RESTful requests target a resource

  • when a web service access a resource, the requester receives a representation of the resource. If the retrieve request succeeds, a typed representation of resource (ex. text/html) is transferred from the machine hosting the service.
  • When a RESTful client accesses a resource it does two things: names the resource by giving its URI and specifies the verb (HTTP method) that indicates the operation the client wishes to do (create a new resource, retrieve a resource, update an existing resource and delete an existing resource)
  • In practice, a RESTful request contains the name of the resource and the client operation on the resource
    RESTful request ≡ resource’s URI + client operation

In the REST, HTTP works as an API

  • HTTP has its methods: each method corresponds to a CRUD operation.
    HTTP methodCRUD operation
    POST Create
    GET Retrieve
    UPDATE Update
    DELETE Delete
  • HTTP has its response code. For example 200 Response Success, 404 Not Found and 500 Internal Server Error
  • To sum up, HTTP gives methods and MIME types to client requests, HTTP provides service responses with status codes and MIME types.

No comments :

Post a Comment