Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Web Services (502449-3)

Lecture 01: Introduction to Web Services


Dr. Raneem Yousif Alyami

Assistant Professor, Information Technology Department


College of Computers and Information Technology, Taif University
Contact Information
E-mail : rayami@tu.edu.sa
Office Number: TBU
Web Services [502449] 1
Contents
• Motivation for the Course
• Objectives of the Course
• Introduction to Web Services
• Web Services Standards
• XML Basics
• Web Services Architecture
• Application Integration
• Web Service Components
• WSDL
• Defining WSDL Services
• UDDI Web Services [502449] 2
Motivation for the Course
Overview of Technology
• Web services have not appeared out of the blue but are the result of
the natural evolution of middleware and enterprise application
integration platforms as they try to leverage the WWW, the Internet
and the globalization of society as a whole, particularly in its
economic aspects
• A key to understanding Web services, how they are and how they
might evolve is understanding how we got there and what the
relation of Web services with existing technology is. This relation is
inescapable as only from this perspective is it possible to understand
what is happening in the Web services world.

Web Services [502449] 3


Motivation for the Course (con’t)
Web Services
• Web services have captured the attention of many companies and
vendors. We are currently witnessing a flurry of activity almost
without precedent in the computer industry. New proposals appear
every month, many of them never to be heard of again.
• The nature of Web services and the motivation to use them is often
blurred by hype as well as the many contradictory and overlapping
proposals and specifications out there.
• The questions we will try to answer in this course are: what are Web
services? What can be done with Web services today?

Web Services [502449] 4


Objectives of the Course
Understanding Web Services
• In order to understand Web services, we need to take a step back
and look at the way middleware and enterprise application
integration technology has been evolving in the last decades. Only so
we will then be able to understand Web services.
• The most popular version of Web services (SOAP, UDDI, and WSDL) is
a very poor and limiting view on what true Web services should be.
Alternative proposals such as ebXML, xCBL, or RosettaNet provide a
much deeper insight on what is needed for electronic commerce
through Web services.

Web Services [502449] 5


Objectives of the Course (con’t)
Putting Web Services into Perspective
• We will go over the basic Web service technology available today and
discuss SOAP, UDDI and WSDL in detail.
• We will also discuss what can be done with these specifications and
what is missing nowadays for them to be truly useful tools for
electronic commerce.
• The course aims at developing a critical understanding of Web service
technology and its possibilities today. The goal is for participants to
be able to look at current and future developments with enough
background to be able to judge how much of a contribution they are
and what their true potential is.

Web Services [502449] 6


Introduction to Web Services
What is a Web Service?

• A web service is any piece of software that makes itself available over the
internet and uses a standardized XML messaging system.

• Web services are self-contained, modular, distributed, dynamic applications that


can be described, published, located, or invoked over the network to create
products, processes, and supply chains.

• A web service is a collection of open protocols and standards used for exchanging
data between applications or systems.

• Software component stored on one computer that can be accessed via method
calls by an application on another computer

Web Services [502449] 7


Introduction to Web Services (con’t)
• A Web Service is a method of communication between two electronic
devices over the World Wide Web. A Web Service is a software function
provided at a network address over the web or the cloud

Also it can be defined by following ways:


• Is a collection of standards or protocols for exchanging information
between two devices or application
• Web services are self-contained and self-describing
• Web services can be discovered using UDDI
• Web services can be used by other applications
• XML is the basis for Web service

Web Services [502449] 8


Web Services Standards
• XML is used to tag the data,
• SOAP is used to transfer the data,
• WSDL is used for describing the services available,
• UDDI is used for listing what services are available, and
• REST provides communication between software applications
running on different platforms and frameworks.

Web Services [502449] 9


XML Basics
• XML eXtensible Markup Language – A uniform data representation and
exchange mechanism
• XML is a super set of HTML. A user can define his/her own tags in XML.
• Any XML documents must conform their metadata such as Document Type
Definition (DTD) or XML Schema (XSD) which specifies complex data types,
elements and its attributes, and its sub-elements, etc. An XML document
can be used to represent and transfer structured data in the hierarchy of
element tags.
• An XML documents with its XML Schema or DTD can be recognized by any
program or software easily as long as XML API is supported.
• An XML document is a universal format document type used for data
exchange and data storage. XML is also widely used for deployment
descriptors and configuration specifications.

Web Services [502449] 10


XML Basics (con’t)
• Example:
<?xml version=1.0 ?>
<content>
<name>Joun Doe</name>
<address>2 Backroads Lane</address>
<country>New York</country>
<phone>045935435</phone>
<email>john.doe@gmail.com</email>
</content>

• The information contained is being marked, but not for displaying.


• Readable by both human and machines.

Web Services [502449] 11


Web Services Architecture
The two competing views of Web services are:

• Bottom up: Application Integration


• Top down: Business Exchanges

Next, we will study the bottom up approach and descuss the top-down
approach later.

Web Services [502449] 12


Web Services Architecture: Application Integration
A popular interpretation of Web services is based on IBM’s
Web service architecture based on three elements:
Web
Service
• Service requester: The potential user of a service.
Registery

• Service provider: The entity that implements the service 2. find 1. publish
and offers to carry it out on behalf of the requester

• Service registry: A place where available services are Web Web


Service Service
listed and which allows providers to advertise their Client Provider
services and requesters to query for services 3. bind/invoke

• The goal is just-in-time integration of applications by


discovering and orchestrating network-available services

Web Services [502449] 13


Web Service Components
There are four major Web service components:
• WSDL - Web Services Description Language – A
standard meta language to described the
services offered.
• UDDI - Universal Description, Discovery and
Integration specification – A mechanism to
register and locate WS based application
• SOAP - Simple Object Access Protocol – A
standard way for communication
• REST - Representational State Transfer – A
software architectural model which is used to
describe distributed systems like WWW
Web Services [502449] 14
WSDL
• WSDL is a xml document containing information about web services such as method
name, method parameter and how to access it.
• WSDL is a part of UDDI. It acts as an interface between web service applications.
• WSDL is pronounced as wiz-dull.
• A WSDL description of a web service (also referred to as a WSDL file) provides a
machine-readable description of how the service can be called what parameters it
expects and what data structures it returns.
• WSDL was developed jointly by Microsoft and IBM initially.
• WSDL is often used in combination with SOAP and XML Schema to provide web
services over the Internet.
• A client program connecting to a web service can read the WSDL to determine what
functions are available on the server.
• The client can then use SOAP to actually call one of the functions listed in the WSDL.

Web Services [502449] 15


Defining WSDL Services
1. Define in XML Schema the message types used when invoking the service: MT1,
MT2 etc.
2. Define (named) messages by using these types, e.g.
• message m1 has type MT1
• message m2 has type MT2 etc.
3. Define Services that consist of one or more operations; each operation is
implemented by the exchange of messages
• service S offers operation O1; for executing O1 first send a request message m1, then a
response message m2 is returned
4. Define a Binding B to a specific protocol, e.g. SOAP
• service S is implemented in SOAP; the SOAP messages are constructed from the abstract
messages m1 and m2 by, e.g. inlining the message as body of SOAP messages
5. Service S is provided with binding B at the following URI's (called ports)

Web Services [502449] 16


UDDI
• UDDI is a XML based framework for describing, discovering and integrating web
services.
• UDDI is a directory of web service interfaces described by WSDL, containing
information about web services.
• Defines a way to publish and discover information about web services.
• “Web service” describes specific business functionality to be used by another
company.
• It represents technical specification for publishing and finding businesses and
Web services.
• UDDI is a platform-independent framework for describing services, discovering
businesses, and integrating business services by using the Internet.
• UDDI is a directory for storing information about web services.
• UDDI is a directory of web service interfaces described by WSDL
Web Services [502449] 17
UDDI (con’t)
Use XML-based description files for services
o Main components
• White pages: basic contact information about an organization
• Yellow pages: classification of organization based on industrial categorization
• Green pages: technical description of services offered by registered organizations
o Access to UDDI Registry
• Standard UDDI API (accessible via SOAP)
• Web browser
o Data Structures (XML)
• Business entity: general information + business services
• Business services: business level description + binding templates
• Binding templates: access point + tModel (service types)
• tModel: abstract definition of a web service 31

Web Services [502449] 18


SOAP
• SOAP is a XML-based protocol for accessing web services.
• SOAP is a W3C recommendation for communication between applications.
• SOAP is XML based, so it is platform independent and language independent. In other
words, it can be used with Java, .Net or PHP language on any platform.
Advantages
WS Security: SOAP defines its own security known as WS Security.
Language and Platform Independent: SOAP web services can be written in any
programming language and executed in any platform.
Disadvantages
Slow: SOAP uses XML format that must be parsed to be read. It defines many standards
that must be followed while developing the SOAP applications. So, it is slow and consumes
more bandwidth and resource.
WSDL Dependent: SOAP uses WSDL and doesn't have any other mechanism to discover
the service. Web Services [502449] 19
SOAP (con’t)
• In simple words, SOAP is a
technique to send an XML
request over the Internet using
HTTP protocol (hitting a URL),
and in return getting an XML
response.
• Example, if a client wants to
fetch a school's student data, by
sending in the student's Roll No.
in the request, he can do so
using web services. But how will
the client know, which URL to
call and what to send in the
request?
Web Services [502449] 20
SOAP Request
• In the example below, a GetStockPrice request is sent to a server. The request
has a StockName parameter, and a Price parameter that will be returned in the
response (next slide). The namespace for the function is defined in
"http://www.example.org/stock".
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPrice>
<m:StockName>IBM</m:StockName>
</m:GetStockPrice>
</soap:Body>

</soap:Envelope> Web Services [502449] 21


SOAP Response
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
</m:GetStockPriceResponse>
</soap:Body>

</soap:Envelope>

Web Services [502449] 22


REST
• REST stands for Representational State Transfer.
• It is a software architectural model which is used to describe distributed systems
like WWW (World Wide Web).
• REST is about resources and how to represent resources in different ways.
• REST is an architectural style not a protocol nor a standard.
• It has been developed in parallel with HTTP protocol. However, REST uses
existing standards, e.g., HTTP.
• REST is an architecture all about the Client-Server communication.
• Appeals to developers because it has a simpler style that makes it easier to use
than SOAP but not replacement for SOAP. (REST is more recent than SOAP)
• It is also less verbose so that less volume is sent when communicating.
• The applications which follow this architecture are referred to as RESTful
Web Services [502449] 23
REST (con’t)
Advantages
• Scalable component interactions
• General interfaces
• Independently deployed connectors.
• Reduced interaction latency.
• Strengthened security.
• Safe encapsulation of legacy systems.
• Separates server implementation from the client’s perception of resources (“Cool
URIs Don’t Change”).
• Scales well to large numbers of clients.
• Enables transfer of data in streams of unlimited size and type.
Web Services [502449] 24
REST (con’t)
Disadvantages
• It sacrifices some of the advantages of other architectures
• Stateful interaction with an FTP site
• It retains a single interface for everything

Web Services [502449] 25


REST (con’t)
• Unlike SOAP which targets the actions, REST concerns more on the
resources.
• REST locates the resources by using URL and it depends on the type
of transport protocol (with HTTP - GET, POST, PUT, DELETE,...) for the
actions to be performed on the resources.
• The REST service locates the resource based on the URL and performs
the action based on the transport action verb. It is more of
architectural style and conventions based.

Web Services [502449] 26


REST (con’t)
For Example: in a RESTful
architecture, this
URL http://{serverAddress}/stude
nts/studentRollno/07 can be used
to:
• get student information by
sending a REST call of GET type,
and the service will return
information of student with roll
no as 07
• The same service can also be
used to update the student data,
by sending in the new values as
Form data in a PUT request.
Web Services [502449] 27
REST Request
GET /news/ HTTP/1.1
Host: example.org
Accept-Encoding: compress, gzip
User-Agent: Python-httplib2
</soap:Envelope>

• Here is a GET request to “http://example.org/news/”


• Method = GET

Web Services [502449] 28


REST Response
HTTP/1.1 200 Ok
Date: Thu, 07 Aug 2008 15:06:24 GMT
Server: Apache
ETag: "85a1b765e8c01dbf872651d7a5"
Content-Type: text/html
Cache-Control: max-age=3600

<!DOCTYPE HTML>
...

Web Services [502449] 29


Differences Between SOAP and REST

Web Services [502449] 30

You might also like