Web services allow programs to communicate over the web through APIs and make requests to access resources and services. There are two main types - SOAP-based and RESTful web services. RESTful services use HTTP methods like GET and POST to operate on resources identified through URIs. They transfer representations of resources in formats like JSON and XML. A key REST principle is that resources are accessed through a uniform interface, with clients requesting state transfers of representations through stateless operations.
2. What are the Web Services ?
2
Application Programming Interfaces (API)
Request Services
REST Architecture
SOA Architecture
OASIS
World Wide Web Consortium (W3C )
3. What is Web Services ?
3
Web Services are evolving, middleware platform that facilitate program-to-program
interactions.
A service is a software entity that can be discovered and invoked by other software
systems.
Definition from standardization body W3C :
A Web service is a software system identified by a URI, whose public interfaces
and bindings are defined and described using XML. Its definition can be
discovered by other software systems.These systems may then interact with the
Web service in a manner prescribed by its definition, using XML based
messages conveyed by internet protocols.
Web services are self contained, self describing, modular applications that can be
published, located, and invoked across the web. Web services perform functions,
which can be anything from simple requests to complicated business processes".
5. 5
How does a Web Service Work ?
The client sends a request
Request encoded in XML
Function (GET, POST) in the file
The server decodes the file
The function is executed
A new XML file is encoded and re-send to the
client
Clients and servers communicate over the
HyperText Transfer Protocol (HTTP).
6. 6
Types of Web Services
Can be classified as Big web services and RESTful web services.
Big web services are based on SOAP standard and often contain a WSDL to describe
the interface that the web service offers.
Big web services includes architecture to address complex non-functional
requirements like transactions, security, addressing, trust, coordination, and also
handles asynchronous processing and invocation.
SOAP based Web Services is a great solution when you need,
Asynchronous processing
Reliability
Stateful operations
7. 7
RESTful Web Services
REST is a term coined by Roy Fielding to describe an architecture style of networked
systems. REST is an acronym standing for Representational State Transfer.
It is an architectural pattern for developing web services as opposed to a specification.
"Representational State Transfer is intended to evoke an image of how a well-designed
Web application behaves: a network of web pages (a virtual state-machine), where the
user progresses through an application by selecting links (state transitions), resulting in the
next page (representing the next state of the application) being transferred to the user and
rendered for their use."
Roy Fielding...
REST web services communicate over the HTTP specification, using HTTP
vocabulary:
Methods (GET, POST, etc.)
HTTP URI syntax (paths, parameters, etc.)
Media types (xml, json, html, plain text, etc)
HTTP Response codes.
8. 8
Introduction to REST
Representational
Clients possess the information necessary to identify, modify, and/or delete a web
resource.
State
All resource state information is stored on the client.
Transfer
Client state is passed from the client to the service through HTTP.
The six characteristics of REST:
Uniform interface
Decoupled client-server interaction
Stateless
Cacheable
Layered
Extensible through code on demand (optional).
* Services that do not conform to the above required constraints are not strictly
RESTful web services.
9. Example : Web-Based Reservation Service
9
Suppose now the airline (AirIndia.com) wants to provide a Web reservation service for
customers to make flight reservations through the Web.
There are two main approaches to implementing the Web reservation service.
Approach 1
One-Stop Shopping
10. Continued...
10
Approach 1 Diadvantages :
There is currently no industry accepted practice (rules) for expressing priorities.
It violates Tim Berners-Lee Web Design, Axiom 0 (all resources on the Web must be
uniquely identified with a URI).
Approach 2:
URLs are Cheap! Use Them!
11. 11
Continued...
Approach 2 Advantages :
The different URLs are discoverable by search engines and UDDI registries.
There is no need to introduce rules. Priorities are elevated to the level of a URL. "What
you see is what you get."
It's easy to understand what each service does simply by examining the URL, i.e., it
exploits the Principle of Least Surprise.
It's easy to implement high priority - simply assign a fast machine at the premier
member URL.
There is no bottleneck and consistent with Axiom 0.
12. 12
RESTful Web Services : HTTP and REST
HTTP-REST Request Basics
The HTTP request is sent from the client.
Identifies the location of a resource.
Specifies the verb, or HTTP method to use when accessing the resource.
Supplies optional request headers (name-value pairs) that provide additional
information the server may need when processing the request.
Supplies an optional request body that identifies additional data to be uploaded to
the server
HTTP-REST Request Basics
The HTTP response is sent from the server.
Gives the status of the processed request.
13. 13
Continued...
Supplies response headers (name-value pairs) that provide additional information
about the response.
Supplies an optional response body that identifies additional data to be
downloaded to the client
A REST service framework provides a controller for routing HTTP requests to a request
handler according to:
The HTTP method used (e.g. GET, POST)
Supplied path information (e.g /service/listItems)
Query, form, and path parameters
Headers, cookies, etc.
15. Resources
15
The key abstraction of information in REST is a resource.
A resource is a conceptual mapping to a set of entities
Represented with a global identifier (URI in HTTP)
http://www.boeing.com/aircraft/747
REST uses URI to identify resources
http://localhost/classes
http://localhost/classes/cs2650
http://localhost/classes/cs2650/students
As we traverse the path from more generic to more specific, we are navigating the
data.
16. 16
Verbs
Represent the actions to be performed on resources
HTTP GET
How clients ask for the information they seek.
HTTP POST
HTTP POST creates a resource
HTTP PUT
HTTP PUT updates a resource
HTTP DELETE
Removes the resource identified by the URI
17. 17
Representations
How data is represented or returned to the client for presentation
Two main formats:
JavaScript Object Notation (JSON)
XML
It is common to have multiple representations of the same data
XML
<COURSE>
<ID>CS2650</ID>
<NAME>Distributed Multimedia Software</NAME>
</COURSE>
JSON
{course
{id: CS2650}
{name: Distributed Multimedia Sofware}
}
18. 18
Why is it called "Representational State Transfer"?
Client
Resource
http://www.airindia.com/aircraft/111
Fuel requirements
Maintenance schedule
...
airindia111.html