Week 7 Lecture Notes
Week 7 Lecture Notes
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.
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
• WSDL in SOAP is a standardized XML language that defines the interface for
web services.
• 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.
• 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.
• Flexibility
• Compose services on the fly
Summary of SOA Elements
• 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.