Post on 01-Apr-2015
Web Services
What are Web Services?
Today, we normally use Web browsers to talk to Web sites Browser names document via URL (lots of
fun and games can happen here) Request and reply encoded in HTML, using
HTTP to issue request to the site Web Services generalize this model so
that computers can talk to computers using much of the same protocols used to communicate between browsers and web servers + a lot more.
What are Web Services?
The concept of Web Service (WS) was introduced in 1999 by Hewlett-Packard. Microsoft coined the actual term “Web Services” in June 2000 as part of the .NET initiative.
Web services are often advertised as a new wave in business process automation Is suppose to allow a seamless integration of systems and
applications that communicate over the network and share data. This technology is in its infancy.
Work in progress Unproven Lots of hype?
What are Web Services?
Idea of treating software as a service. Nothing new
Evolution of many different technologies Remote Procedure Calls (RPC) CORBA DCOM Java RMI
What is novel? Overwhelming industry support Utilization of XML
Why Web Services
SUN RPC, DEC, CORBA, DCOM, Java RMI Not considered Internet-friendly Interoperability issues: standards are not always clear. Cannot be implemented in any language on any
platform Software components that comprise the application
are often not useful except for that application A web service
Can be implemented in any language on any platform Black boxes
• Component-like, reusable Based on Web standards
• HTTP, XML, SOAP, WSDL, UDDI
Examples of Simple Web Services
Return the distance in miles between 2 locations
Locate entertainment, restaurants and lodging in a given area
Return the name and the postal address associated with a given phone number.
Find ATM location for a given postal code.
Return stock quotes.
Examples of Web Services
A travel agent needs to book a flight, hotel and car in a warm place. The client wants the best prices. Travel agent contacts each airline for flight information, hotel chain for hotel information and car rental agencies. The airlines, hotel chains and car rental
agencies can be thought of as web services from the travel agent’s perspective.
The travel agent’s user may think of the travel agent as a web service.
Examples of Web Services
You should note the potential reusability of each of the services described on the last two slides.
Web services provide interoperability between various software applications running on various platforms.
Web services leverage open standards and protocols.
Web Services Architecture
(1) Publish
Service Directory
ServiceProvider
ServiceRequestor
(2) Discover Services
(3) Invoke Services
Web Services Architecture
Service Provider Implements the Web Service and makes it
available on the Internet Service Requestor
Consumer of the Web Service Service Directory
Logically centralized directory of services Place to publish a new web service or find
existing one.
XML
XML – Extensible Markup Language Open standard for data exchange; for
describing data which allows an infinite range of elements (tags) to be defined: Tags define content Separation of content from presentation
SOAP SOAP – Simple Object Access Protocol
Created by Microsoft and submitted to W3C in 1999 Multivendor support including IBM, Sun, Oracle, HP,
etc; SOAP operates as RPC mechanism with HTTP
used as transport protocol. Encodes requests and responses as XML
documents. SOAP is suppose to be simple, easy to extend
and interoperable.
SOAP Elements Envelope (mandatory)
Top element of the XML document representing the message
Header (optional) Determines how a recipient of a SOAP message should
process the message Adds features to the SOAP message such as
authentication, transaction management, payment, message routes, logging, auditing, etc…
Body (mandatory) Exchanges information intended for the recipient of
the message. Typical use is for RPC calls and error reporting.
Soap RequestSOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<SOAP-ENV:Body> <m:GetLastTradePriceRequest xmlns:m="Some-URI"> <symbol>HP</symbol> </m:GetLastTradePriceRequest> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Identifies XML has SOAP message
Soap RequestSOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<SOAP-ENV:Body> <m:GetLastTradePriceRequest xmlns:m="Some-URI"> <symbol>HP</symbol> </m:GetLastTradePriceRequest> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Get price for HP stock
SOAP Response
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-
URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
WSDL
WSDL – Web Services Description Language
Type of XML used to describe abilities of Web Service to its potential user.
WSLD provides the standard method of describing web services and their specific capabilities to other applications.
Elements in WSDL Definitions Types
Based on XML Schema type system Message formats
Parts represent method parameters Port Types
Set of operations Parameter order Input and output messages
Bindings Map a Port Type to a specific protocol, using a specific data
encoding style Services
Set of ports that implement port types Access point for each port
<definitions>
<types> <!-- XML Schema --> </types>
<message name=“getQuoteRequest” />
<message name=“getQuoteResponse” />
<portType name=“StockQuoteServiceInterface”>
<operation name=“getQuote”>
<input message=“getQuoteRequest” />
<output message=“getQuoteResponse” />
</operation>
</portType>
<binding name=“StockQuoteServiceBinding” type=“StockQuoteServiceInterface”>
<soap:binding transport=“http://schemas.xmlsoap.org/soap/http” />
…
</binding>
<service name=“StockQuoteService”>
<port name=“StockQuoteServicePort” binding=“StockQuoteServiceBinding”>
<soap:address location=“http://www.acme.com/services/stockquote” />
</port>
</service>
</definitions>
WSDL – An Example
Definition of data types
Definition of messages
Definition of port type
Definition of the bindings
Definition of the service
UDDI
UDDI – Universal Description, Discovery, and Integration Enables the creation of searchable web service
directory that allows for the registration of a service and in response to a user provide the location of a service.
Search by business or service type Has a Web Services API for publishing and discovering
the existence of Web services A coalition of organizations working together to manage
UDDI registries and to further develop the Web Services API for accessing those registries.
How UDDI Works
UDDI Business Registry
3. Assigns a unique identifier to each business registration
Marketplaces, search engines, and business apps query the registry to discover services at other companies
4.SW companies, standards bodies, and programmers populate the registry withdescriptions of different types of services
1.
BusinessRegistrations
2.
Businesses populate the registry withdescriptions of the services they support
Business uses this data to facilitate easier integration with each other over the Web
5.
Web Service Example(from SUN)
Suppose that the owner of a chain of coffee houses, called Coffee Break, wants to expand by selling coffee online.
The owner instructs the business manger to find some new coffee supplier, get their wholesale prices, and then arrange for orders to be placed as the need arises.
Coffee Break can analyze prices and decide which new coffees it wants to carry and which companies it wants to buy them from.
Web Services Example (from SUN)
Locate coffee supplier through a UDDI service directory.
The Coffee Break will issue a query to the UDDI service directory. When the search is completed, the registry will send back information on how to contact the wholesale coffee distributors that meet the criteria set out in the query.
Web Services Example
Now Coffee Break can request price lists from each of the coffee distributors returned by the UDDI Service Directory. The Coffee Break has obtained a WSDL
description for each distributor which describes the procedure to call to get prices and the URL where the request is to be sent.
Upon receiving the responses for the request for prices, Coffee Break processes the price lists. This is used to send orders.
Traditional RPC vs Web Services
Traditional RPC Within enterprise Tied to a set of
programming languages
Procedural Usually bound to a
particular transport Tightly-coupled Firewall-unfriendly Efficient processing
Web Services Between enterprises Program language
independent Message-driven Easily bound to
different transports Loosely-coupled Firewall-friendly Relatively not
efficient processing
Challenges Standards are new and require further
development as to make sure that there is true interoperability.
Lack of Security Controversy over royalty fees (intellectual
property rights to SOAP, WSDL, UDDI are held by Microsoft and IBM).
Management, monitoring, auditing Performance: WS may be too slow for high
performance applications since parsing XML takes time.
Quality of Service: Lack of standards describing quality of various web services.