0% found this document useful (0 votes)
3 views

Week 7 Lecture Notes

This document provides an overview of services, focusing on Service-Oriented Architecture (SOA), web services, and RESTful APIs. It explains the characteristics of services, the role of SOAP and WSDL in web services, and compares REST and SOAP in terms of their use cases and advantages. The document emphasizes the importance of open standards, loose coupling, and flexibility in designing and implementing services for modern applications.

Uploaded by

suayilseven764
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Week 7 Lecture Notes

This document provides an overview of services, focusing on Service-Oriented Architecture (SOA), web services, and RESTful APIs. It explains the characteristics of services, the role of SOAP and WSDL in web services, and compares REST and SOAP in terms of their use cases and advantages. The document emphasizes the importance of open standards, loose coupling, and flexibility in designing and implementing services for modern applications.

Uploaded by

suayilseven764
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

COMP 301 Lecture 7

Fall 2023
What is Service?
Web Services, SOA Services and REST(ful) Service
What is a Service?
• A service is a reusable component that can be used as a building block
to form larger, more complex business-application functionality.

• A service may be as simple as “get me some person data,” or as


complex as “process a disbursement.”
What is a Service?
• A service provides a discrete business function that operates on data.
• Its job is to ensure that the business functionality is applied
consistently, returns predictable results, and operates within the
quality of service required.
What is a Service?
• How the service is implemented, and how a user of the service
accesses it.

• From a theory point of view, it really doesn’t matter how a service is


implemented.
Characteristics of a Service
• Supports open standards for integration: Although proprietary
integration mechanisms may be offered by the SOA infrastructure,
SOA’s should be based on open standards. Open standards ensure
the broadest integration compatibility opportunities.
Characteristics of a Service
• Loose coupling: The consumer of the service is required to provide
only the stated data on the interface definition, and to expect only
the specified results on the interface definition. The service is
capable of handling all processing (including exception processing).
Characteristics of a Service
• Stateless: The service does not maintain state between invocations.
It takes the parameters provided, performs the defined function, and
returns the expected result. If a transaction is involved, the
transaction is committed and the data is saved to the database.
Characteristics of a Service
• Location agnostic: Users of the service do not need to worry about
the implementation details for accessing the service. The SOA
infrastructure will provide standardized access mechanisms with
service-level agreements.
Service Oriented Architecture
• Service-Oriented Architecture (SOA) is a style of
software design where services are provided to the
other components by application components, through
a communication protocol over a network
• Its principles are independent of vendors and other
technologies.
• In service oriented architecture, a number of
services communicate with each other, in one of two
ways:
 through passing data
 through two or more services coordinating an activity
What is Service-Oriented
Architecture?
• Service-Oriented Architecture (SOA) is an architectural style.
• Applications built using an SOA style deliver functionality as services
that can be used or reused when building applications or integrating
within the enterprise or trading partners.
Simple Object Access Protocol(SOAP)
SOAP
• SOAP is an acronym for Simple Object Access Protocol is a network
platform used in web services for exchange/ communication of data
between two different hosts on a network. XML format is used for
data transfer over HTTP protocol.
• Uses open standards to integrate software assets as
services(http,smtp or tcp/ip protocol)
• Standardizes interactions of services(xml)
• Services become building blocks that form business flows.
• Services can be reused by other applications.
SOAP
• SOAP is an acronym for Simple Object Access
Protocol is a network platform used in web
services for exchange/ communication of data between
two different hosts on a network. XML format is used for
data transfer over HTTP protocol. In web services SOAP
let the user interact with other programming languages
and provides a way of communication between
applications running on diverse operating systems such
as Linux, AIX, Windows and so on. SOAP acts as an
application of the XML specification.
The SOA Framework
Discovery
Services

Find Service Publish Service


Description

Use Service
Service
Client Provider
Call flow to a service
2. Discovery 1. Publishing

3. YP Lookup
Registry

Client
4. Request
Service Providing
4. Request Peers

5. Async Reply
SOAP
SOAP Message
SOAP Message Example

1.Envelope: Declaration of the XML


namespace
2.Header: Message header data (for
example, message ID)
3.Body: Data of the actual message (for
example, order number, material)
Another SOAP Message
The SOAP envelope
<Envelope> is the root element in every SOAP message, and
contains two child elements, an optional <Header> element,
and a mandatory <Body> element.
The SOAP header
<Header> is an optional subelement of the SOAP envelope, and
is used to pass application-related information that is to be
processed by SOAP nodes along the message path; see The
SOAP header.
The SOAP body
<Body> is a mandatory subelement of the SOAP envelope,
which contains information intended for the ultimate recipient
of the message; see The SOAP body.
The SOAP fault
<Fault> is a subelement of the SOAP body, which is used for
reporting errors; see The SOAP fault.
What is WSDL in SOAP?
• WSDL stands for Web Services Description Language and it’s
fundamental for web services within the SOAP protocol

• WSDL in SOAP is a standardized XML language that defines the interface for
web services.

• It outlines how to communicate using SOAP, which operations are available,


and what input and output they require.

• It offers a way for service providers to describe the basic format of requests to
their systems, regardless of the application-level protocol they use.
WSDL
• It offers a way for service providers to describe the basic format of requests to
their systems, regardless of the application-level protocol they use.

• This interface description includes things like the data types of messages, a list
of operations that the service exposes, the communication protocols used, and
more.
• This allows anyone who wants to interact with the service to know exactly
what is required of them.
How Does WSDL in SOAP Work?
WSDL in SOAP primarily works by defining the web service in a clear, machine-readable
format.

It provides a blueprint that describes how to interact with the web service, detailing the
methods and properties of the SOAP messages.

At a high level, a WSDL document includes definitions, types, messages, port types,
bindings, and services.

• ‘Definitions’ serve as a container for all other components.


• ‘Types’ describe the data types to be used.
• ‘Messages’ represent abstract definitions of the data being transmitted.
• ‘Port Types’ are abstract collections of operations.
• ‘Bindings’ specify concrete protocols and data formats for the operations and
messages defined, and ‘Services’ group together a set of related ports.
WSDL Elements
WSDL Document Example
Another Example
SOA Benefits
• The services model mimics business needs better than objects or resources
• IT Services (virus detection and elimination service)
• Marketing services (promotional campaigns, brand marketing programs etc.)
• Accounting services (Audits, Quarterly statements etc.)

• Loose coupling between consumer and provider


• Allows us to improve availability by having redundant providers.

• Dynamic binding allows the use of the latest services that are most useful to the
task at hand.
• In a highly adhoc networked environment, “discovery” becomes critical – yellow pages model over white pages.

• Allows you to leverage existing IT assets – is a evolutionary architecture not a


revolutionary one.
SOA Benefits - 2
• More cost efficient from an IT perspective:
• Computing as a utility rather than as infrastructure
• Use as you need model
• Reuse

• Flexibility
• Compose services on the fly
Summary of SOA Elements

• Loose coupling: focus should be on high-level contractual relationships


• Implementation neutrality: the interface is what should matter
• Flexible configurability: late binding of components
• Long lifetime: components should exist long enough to be discovered, to be relied upon, and to
engender trust in their behavior
• Granularity: interactions and dependencies should occur at as high a level as possible
• Teams: computation in open systems should be conceptualized as business partners working as a
team
Examples of SOA Frameworks
• Jini
• Java based
• Incorporates discovery, leasing, anonymous routing.
• Takes advantage of code mobility afforded by Java
• Web services
• Open standards based
• Uses XML as the data description format
• Usually runs on open transports such as http.
Web Services
Web Processes
• Web processes are the next generation of workflow technology to
facilitate the interaction of organizations with markets, competitors,
suppliers, customers etc. supporting enterprise-level and core
business activities
• encompass the ideas of both intra and inter organizational workflow.
• can use BPEL4WS to represent composition.
How will they be used?
The next generation Internet
• HTML and browsers were computer to human communication
• Universal human to application access

• Web services are for program to program communication


• Separated by program, machine, operating system and organizational
boundaries
• Universal application to application access
What is a Web service?
• Application capability, function or operation exposed to
other programs via open, interoperable standards

• “payloads” defined as XML documents

• “transports” over http or other open Internet protocol

• Can be access from any programming language, hardware


platform or operating system
What is a “Good Web Service”?
• “self describing”
• XML Schema or DTD for grammar of payload
• human readable instances

• discoverable
• UDDI, WS-Inspection, or some other method of advertising availability
• Realize promise of many to many integrations that are enabled by a web
service (one to one ad hoc integrations can be done with earlier technology)

• “coarse grained”
• Large documents representing entire business events or business objects
• e.g. CRUD operations: CreateOrder, ReadOrder, UpdateOrder, DeleteOrder
• NOT operations such as SetPrice(), SetProduct(), SetCustomer(),
CompleteOrder()

• asynchronous
• When appropriate (often for large scale work)
Base Protocols in Web Services

Source: CBDI
How web service Works?
Java Web Service API
• here are two main API's defined by
Java for developing web service
applications since JavaEE 6.
• 1) JAX-WS: for SOAP web services.
The are two ways to write JAX-WS
application code: by RPC style and
Document style.
• 2) JAX-RS: for RESTful web
services. There are mainly 2
implementation currently in use for
creating JAX-RS application: Jersey
and RESTeasy.
REST API
• An API, or application programming interface, is a set of rules
that define how applications or devices can connect to and
communicate with each other.
• A REST API is an API that conforms to the design principles of
the REST, or representational state transfer architectural style.
• For this reason, REST APIs are sometimes referred to RESTful
APIs.
• REST provides a relatively high level of flexibility and freedom
for developers. This flexibility is just one reason why REST APIs
have emerged as a common method for connecting
components and applications in a microservices architecture.
What is API?
• An API is a set of definitions and protocols for building
and integrating application software.
• It’s sometimes referred to as a contract between
an information provider and an information user
• In other words, establishing the content required from
the consumer (the call or request) and the content
required by the producer (the response)
API Definition
Simple API Example: Weather
Condition
• For example, the API design for a weather service could
specify that the user supply a zip code and that the
producer reply with a 2-part answer, the first being the
high temperature, and the second being the low.
• You can think of an API as a mediator between the users
or clients and the resources or web services they want
to get.
• Advantage of an API is that you don’t have to know the
specifics of caching—how your resource is retrieved or
where it comes from.
REST(full) API
• At the most basic level, an API is a mechanism that
enables an application or service to access a resource
within another application or service.
• The application or service doing the accessing is called
the client, and the application or service containing the
resource is called the server.
• Some APIs, such as SOAP or XML-RPC, impose a strict
framework on developers.
• But REST APIs can be developed using virtually any
programming language and support a variety of data
formats
RESTful API
• When a client request is made via a RESTful API, it
transfers a representation of the state of the
resource to the requester or endpoint.
• This information, or representation, is delivered in one of
several formats via HTTP: JSON (Javascript Object
Notation), HTML, XLT, Python, PHP, or plain text.
• REST API has these criteria to conform to, it is still
considered easier to use than a prescribed protocol like
SOAP (Simple Object Access Protocol), which has specific
requirements like XML messaging, and built-in security and
transaction compliance that make it slower and heavier.
REST
REST API
HTTP
URL
REST
REST
When to use which? REST or
SOAP?
• Limited bandwidth and resources; remember the return
structure is really in any format (developer defined). Plus, any
browser can be used because the REST approach uses the
standard GET, PUT, POST, and DELETE verbs. Again, remember
that REST can also use the XMLHttpRequest object that most
modern browsers support today, which adds an extra bonus of
AJAX.
• Totally stateless operations; if an operation needs to be
continued, then REST is not the best approach and SOAP may fit it
better. However, if you need stateless CRUD (Create, Read, Update,
and Delete) operations, then REST is it.
• Caching situations; if the information can be cached because of
the totally stateless operation of the REST approach, this is perfect.
When to use which? REST or
SOAP?
• Asynchronous processing and invocation; if your application
needs a guaranteed level of reliability and security then SOAP 1.2
offers additional standards to ensure this type of operation. Things
like WSRM – WS-Reliable Messaging.
• Formal contracts; if both sides (provider and consumer) have to
agree on the exchange format then SOAP 1.2 gives the rigid
specifications for this type of interaction.
• Stateful operations; if the application needs contextual
information and conversational state management then SOAP 1.2
has the additional specification in the WS* structure to support those
things (Security, Transactions, Coordination, etc). Comparatively, the
REST approach would make the developers build this custom
plumbing.

You might also like