Lecture Week04 Web Services
Lecture Week04 Web Services
Services
• "How can different software systems, built with different technologies and
running on different platforms, communicate and exchange data effectively?“
• "How can we build applications that are modular, reusable, and can easily
integrate with other systems?“
• "How can we expose our application's functionality to other developers or
businesses in a standardised way?"
What Are Web Services?
Key Characteristics:
Interoperability: Facilitates Reusability: Encourages the Accessibility: Ensures easy
seamless communication development of modular and access to data and functionalities
between diverse systems. reusable code components. over the web.
What are web services?
Traditional Approach:
• Work with banks and understand complex financial regulations.
• Build secure systems to handle sensitive credit card information.
• Implement fraud detection and security measures
01 02 03 04
Dramatically cut Reduce or Simplify Significantly
application eliminate many application reduce time-to-
development errors maintenance and market.
costs customization
Characteristics of Web
Services
Standardization
01 02 03
Serialisation Involves the Use of standard protocols Service Description: WSDL
use of established norms (e.g., SOAP, REST): leverage (Web Services Description
and protocols to ensure standardized communication Language). OpenAPI
consistency and protocols like SOAP (Simple (formerly Swagger)
interoperability. Object Access Protocol) and
REST (Representational State
Transfer) to enable seamless
data exchange between
applications.
How Does Serialization Work?
Each airline might have its own API for providing flight data, with different formats and protocols.
By using protocols like SOAP or REST, airlines can expose their data in a consistent way, making it
easier for your website to understand and interpret the information.
Additionally, standards for data formats like JSON or XML ensure the structure of the information
is consistent, removing the need for complex parsing and adaptation.
Interoperability
Imagine an online store that wants to streamline its order fulfillment process.
The Problem: The store's systems are a combination of older software and more recent
additions:
• Its inventory management system runs on a Java platform.
• The shipping provider offers a .NET-based API for calculating rates and generating labels.
• The payment processing is handled by a third-party SaaS platform with a RESTful API.
The Goal: Make all these systems communicate seamlessly for automated order
processing, regardless of their underlying technologies.
Discoverability
Discoverability refers to the ability to find and locate web services efficiently.
Methods for discovering and locating services: Various methods, such as service
directories, registries, and standardized protocols, are employed to discover and
locate web services within a network.
Reliability: Ensuring that services Performance: Optimizing Scalability: The ability of the Security: Ensuring the
are available and function response times, throughput, and system to handle increased load confidentiality, integrity, and
correctly, with minimal downtime resource utilization to deliver by adding resources or nodes. authenticity of data and
and errors. services efficiently. communication.
Best practices for reliability!
Availability: Fault tolerance: Data integrity:
• It should have minimal • recover from failures and • It should handle data
downtime or disruptions continue operating without validation, ensure proper
significant impact on its data storage, and prevent
functionality or performance. data corruption or loss.
Documentation and
support:significantly
impacting
Management
VERSIONING:
MANAGING DIFFERENT
VERSIONS OF SERVICES
AND ENSURING
COMPATIBILITY.
Web Standards (W3C)
Is an international community that develops standards and
guidelines to ensure the long-term growth and accessibility of
the World Wide Web
Responsible for developing and maintaining a wide range of
technical specifications and guidelines that define the
technologies used on the web.
Bringing together various stakeholders including industry
leaders, researchers, developers, and public interest groups.
SOAP
Versions
• SOAP 1.1 and SOAP 1.2 are the widely used versions.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:m="http://www.example.org">
<soap:Header>
<!-- Header content here -->
</soap:Header>
<soap:Body>
<!-- Body content here -->
</soap:Body>
</soap:Envelope>
SOAP
XML-based:
• SOAP messages are structured XML documents. This makes them platform-independent and human-
readable (though slightly verbose).
Envelope Structure: SOAP messages have a specific structure. They always include
an 'Envelope' element which contains a 'Header' (optional) and a 'Body’.
Header: Can carry extra information like security metadata, routing, or transaction
details.
Body: Contains the actual message payload (e.g., information about a function call
and its parameters).
WSDL
Purpose: An XML-based
language that describes the
capabilities of a web
Stands for: Web Services
service. Think of it as a
Description Language
'contract' defining how a client
application should interact
with the web service.
WSDL
<message name="SubtractRequest">
<part name="num1" type="xsd:int"/>
<part name="num2" type="xsd:int"/>
</message>
<service name="CalculatorService">
<port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="http://www.example.com/calculator/service"/>
</port>
</service>
</definitions>
The implementation and design of a web service
client
REST - Stateless
Communication Each request from the client to the
server must contain all the
information needed to process that
request.
Principles of REST - Client-Server
Architecture
In a RESTful architecture, the server and the client are clearly isolated
from each other.
While the server doesn’t know the user interface, the client doesn’t know
the application’s business logic or how the application persists data.
Principles of REST - Uniform Interface
For example, the HTTP-based REST APIs make use of the standard HTTP
methods (GET, POST, PUT, DELETE, etc.) and the URIs (Uniform Resource
Identifiers) to identify resources.
Principles of REST - Uniform Interface
The core architectural
elements of a RESTful
system - URI
• A URI is a string of characters
used to identify a resource
over the Web.
• The client uses a URI to locate
the resources over Web and
then, sends a request to the
server and reads the
response.
Using an external service's functionality in
your client web service
Obtain API credentials: Read the documentation: Make HTTP requests: Handle the responses:
Many services require API keys or how to make requests, what appropriate HTTP methods (GET, responses may be in various
access tokens endpoints are available, and what POST, PUT, DELETE) to send formats such as JSON, XML, or
data formats are expected. requests to the endpoints others
JSON
Lightweight data interchange format.
Cons: As your app grows, it can be hard to change or scale one part without
affecting everything else.
Designing the Web Service
What does our travel app need to do? Let's list the features:
Book flights
Book hotels
/search-flights
/book-flight
/search-hotels
and so on...