Recent Changes - Search:

Distributed Computing

This website demonstrates using wikis as teaching and learning tool.

The course instructor is also happy to share the teaching materials here with those who find it readable.

Introduction to Web Services and SOA

A Distributed Computing Lecture by Steven Choy

Introduction to Web Services

Reference: Top Ten FAQs for Web Services

What is a Web Service?

  • At a minimum, a Web service is any piece of software that makes itself available over the Internet and uses a standardized XML messaging system.
  • XML is used to encode all communications to a Web service.

Desirable Properties of a Web Service

  • It has a public interface
    • The interface describes all the methods available to clients and specifies the signature for each method
    • Currently, interface definition is accomplished via the Web Service Description Language (WSDL)
  • Web Services Directories
    • There should be some relatively simple mechanism for a Web Service to publish its API
    • (There should be some simple mechanism for interested parties to locate the service and locate its public interface.)
    • The most prominent directory of Web services is currently available via UDDI, or Universal Description, Discovery, and Integration.

Web Service Protocol Stack

  • Service Transport
This layer is responsible for transporting messages between applications. Currently, this includes HTTP, SMTP, FTP, and newer protocols
  • XML Messaging
This layer is responsible for encoding messages in a common XML format so that messages can be understood at either end. Currently, this includes XML-RPC and SOAP.
  • Service Description
This layer is responsible for describing the public interface to a specific Web service. Currently, service description is handled via the WSDL.
  • Service Discovery
This layer is responsible for centralizing services into a common registry, and providing easy publish/find functionality. Currently, service discovery is handled via the UDDI.

Some Illustrations of Web Service

SOAP

  • An XML-based protocol for exchanging information between computers
  • Make use of both XML namespaces and XML Schemas
SOAP Request
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:getWeather
         xmlns:ns1="urn:examples:weatherservice"
         SOAP-ENV:encodingStyle=" http://www.w3.org/2001/09/soap-encoding
         <zipcode xsi:type="
xsd:string">10016</zipcode>
      </ns1:getWeather>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP Response
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:getWeatherResponse
         xmlns:ns1="urn:examples:weatherservice"
         SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding">

         <return xsi:type="xsd:int">65</return>
      </ns1:getWeatherResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

WSDL

  • An XML grammar for specifying a public interface for a Web service
    • Information on all publicly available functions.
    • Data type information for all XML messages.
    • Binding information about the specific transport protocol to be used.
    • Address information for locating the specified service.
  • Examples

UDDI

  • A technical specification for publishing and finding businesses and Web services
    • First, UDDI is a technical specification for building a distributed directory of businesses and Web services.
    • Second, the UDDI Business Registry is a fully operational implementation of the UDDI specification

Introduction to SOA (Service Oriented Architecture)

Reference: What Is Service-Oriented Architecture (by Hao He on September 30, 2003)

Software systems today

  • Some are made too simple to carry out the duties they are supposed to perform
  • Others are made too complex,
    • and the costs of building and maintaining them have rocketed, not to mention the nearly impossible tasks of integrating different systems together
  • How to reach the right level of simplicity?

Loose Coupling

  • Real dependency vs. artificial dependency
Example: If you travel overseas on business, you know that you must bring power adapters along with you or your life will be miserable. The real dependency is that you need power; the artificial dependency is that your plug must fit into the local outlet.
  • The problem of complex software systems:
    • We also create artificial dependencies along with real dependencies.
  • If the artificial dependencies among systems have been reduced, ideally, to their minimum, we have achieved loose coupling.
  • Artificial dependencies should be reduced to the minimum but real dependencies should not be altered.

SOA Defined

  • SOA is an architectural style whose goal is to achieve loose coupling among interacting software agents.
    • A service is a unit of work done by a service provider to achieve desired end results for a service consumer. Both provider and consumer are roles played by software agents on behalf of their owners.

SOA: Architectural Constraints

  • How does SOA achieve loose coupling among interacting software agents?
    • A small set of simple and ubiquitous interfaces to all participating software agents.
    • Descriptive messages constrained by an extensible schema delivered through the interfaces.

Some SOA illustrations

Deriving Web Services from SOA

  • A web service is a SOA with at least the following additional constraints
    • Interfaces must be based on Internet protocols such as HTTP, FTP, and SMTP
    • Except for binary data attachment, messages must be in XML.
  • Three main styles of Web services:
    • SOAP web services
    • REST web services
    • XML-RPC web services

Three Realizations of Web Services

SOAP Web Services

  • A SOAP web service introduces the following constraints:
    • Except for binary data attachment, messages must be carried by SOAP.
    • The description of a service must be in WSDL.
  • A SOAP RPC web service breaks the second constraint required by an SOA.
    • Applications created with SOAP RPC are not interoperable by nature.
    • RPC also tends to be instructive rather than descriptive, which is against the spirit of SOA.

REST Web Services

  • A REST web service is an SOA based on the concept of "resource".
  • Additional constraints:
    • Interfaces are limited to HTTP
    • Most messages are in XML
    • Simple messages can be encoded with URL encoding
    • Service and service providers must be resources while a consumer can be a resource
  • REST = Representational State Transfer (Roy Fielding)
  • The following semantics are defined:
    • HTTP GET is used for obtaining a representation of a resource. A consumer uses it to retrieve a representation from a URI.
    • HTTP DELETE is used for removing representations of a resource.
    • HTTP POST is used for updating or creating the representations of a resource.
    • HTTP PUT is used for creating representations of a resource.
  • REST web services require little infrastructure support apart from standard HTTP and XML processing technologies
  • REST web services are simple and effective because HTTP is the most widely available interface, and it is good enough for most applications

XML-RPC

  • A protocol that uses XML messages to perform Remote Procedure Calls.
    • Requests are encoded in XML and sent via HTTP POST;
    • XML responses are embedded in the body of the HTTP response.
  • XML-RPC = HTTP + XML + Remote Procedure Calls
  • Request
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
   <methodName>weather.getWeather</methodName>
   <params>
      <param><value>10016</value></param>
   </params>
</methodCall>
  • Response
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
   <params>
      <param>
         <value><int>65</int></value>
      </param>
   </params>
</methodResponse>

Web Services in Action

Reference: Flickr Services

REST Web Services in Practice

  • consist of using plain old HTTP to make method calls and you get XML back
  • use GET, POST, PUT, and DELETE calls to access CRUD (Create, Read, Update, Delete) operations on an object
  • Reality: they are more like xml document requests via GET or POST.
  • Example Applications: Yahoo! has a handful of web services that you can access via REST, including its Answers, Local, and Flickr services.
  • To learn more
  • Demonstration with Flickr Web Services API
REST Request and Response Request is shown in URL and response is the XML the browser received then.

XML-RPC Web Services in Practice

  • a remote procedure call protocol which uses XML for marking up both requests and responses
  • XML-RPC requests are specially formatted XML data posted to a URL.
  • XML-RPC is commonly used for blog ping services such as Technorati and Ping-o-Matic.
  • XML-RPC protocol is really simple. You pass requests which contain the method name, and parameters wrapped in xml that defines their data types. The response comes back with similar data.
  • Example from Flickr

SOAP Web Services in Practice

  • accessing a SOAP web service is easy with any language that has SOAP libraries
  • SOAP requests are "envelopes" of specially formatted XML data posted to a URL.
  • point your code to the url of the web service's WSDL
  • PHP5 has a SOAP library that will handle your client and server, but you have to create your own WSDL
  • Example from Flickr

Extra materials for learning more about Web services and SOA

Readings

Resources

Example Applications that access Web Services

Thanks for Reading

If you would rather like to have this lecture note in printed format, please click the print action link in the top right corner.

If you find any problem in this lecture note, please feel free to reach Steven by steven@findaway.hk

Edit - History - Print - Recent Changes - Search
Page last modified on March 14, 2010, at 03:04 PM