Web Programming/Web Services

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Web Services[edit | edit source]

Concepts and examples: https://www.youtube.com/watch?v=7YcW25PHnAA

Find available web service APIs at http://www.programmableweb.com/

Testing Tools[edit | edit source]

Postman - REST client (Chrome app)

apigee.com/console/

RESTful API[edit | edit source]

source: http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069

REST stands for Representational State Transfer, which is an architectural style for networked hypermedia applications. A service based on REST is called a RESTful service. RESTful services should have following properties and features:

Representations[edit | edit source]

RESTful service provides access to these resources, which must represented using a format such as JSON.

Messages[edit | edit source]

The client and service talk to each other via messages. In addition to the message body messages contain metadata such as header - key-value pairs.

Addressing resources[edit | edit source]

REST requires each resource to have at least one URI. A RESTful service uses a directory hierarchy like human readable URIs to address its resources. URI should not say anything about the operation or action, which is determined by the HTTP verb.

Uniform interface[edit | edit source]

RESTful systems should have a uniform interface. HTTP 1.1 provides a set of methods, called verbs (GET, PUT, POST, DELETE, OPTIONS, HEAD), for this purpose. A Safe HTTP method does not make any changes to the resource on the server. An Idempotent HTTP method has same effect no matter how many times it is performed.

Stateless[edit | edit source]

A RESTful service is stateless and does not maintain the application state for any client. A request cannot be dependent on a past request and a service treats each request independently.

Links between resources[edit | edit source]

A resource representation can contain links to other resources like an HTML page contains links to other pages.

Caching[edit | edit source]

Caching is the concept of storing the generated results and using the stored results instead of generating them repeatedly if the same request arrives in the near future. This can be done on the client, the server, or on any other component between them, such as a proxy server.

Documenting a RESTful service[edit | edit source]

A client can simply know the base address of the service and from there it can discover the service on its own by traversing through the resources using links. The method OPTION can be used effectively in the process of discovering a service. Sample documentation of a service can be found at http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=3