Web Services — Part I

Web-Based Services (INFOSYS 290-3)

Erik Wilde, UC Berkeley iSchool
Wednesday, October 4, 2006
Creative Commons License

This work is licensed under a Creative Commons
Attribution-NonCommercial-ShareAlike 2.5 License.

Abstract

Web Services (as the narrowly defined field as opposed to the broader topic of Web-based Services) are usually described as three technologies. The Simple Object Access Protocol (SOAP) is the format which is used to encapsulate XML payload and provides a common envelope format which can be interpreted and processed by all SOAP-aware applications. The Web Services Description Language (WSDL) is used to describe the interface to a Web Service which accepts SOAP messages. Using WSDL, code can be generated to more easily interface with the Web Service. Finally, Universal Description, Discovery, and Integration (UDDI) is a registry which can be used to search for WSDL documents.

The Real World

Outline (Simple Object Access Protocol (SOAP))

  1. Simple Object Access Protocol (SOAP) [7]
  2. Web Services Description Language (WSDL) [10]
  3. Universal Description, Discovery, and Integration (UDDI) [4]
  4. Conclusions [1]

XML Message Format

SOAP Message Structure

SOAP Example Message

<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 <env:Header>
  <m:reservation xmlns:m="http://travelcompany.example.org/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
   <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference>
   <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime>
  </m:reservation>
  <n:passenger xmlns:n="http://mycompany.example.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true">
   <n:name>Åke Jógvan Øyvind</n:name>
  </n:passenger>
 </env:Header>
 <env:Body>
  <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel">
   <p:departure>
    <p:departing>New York</p:departing>
    <p:arriving>Los Angeles</p:arriving>
    <p:departureDate>2001-12-14</p:departureDate>
    <p:departureTime>late afternoon</p:departureTime>
    <p:seatPreference>aisle</p:seatPreference>
   </p:departure>
   <p:return>
    <p:departing>Los Angeles</p:departing>
    <p:arriving>New York</p:arriving>
    <p:departureDate>2001-12-20</p:departureDate>
    <p:departureTime>mid-morning</p:departureTime>
    <p:seatPreference/>
   </p:return>
  </p:itinerary>
  <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels">
   <q:preference>none</q:preference>
  </q:lodging>
 </env:Body>
</env:Envelope>

Some Observations

SOAP Fault Message

<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">
 <env:Body>
  <env:Fault>
   <env:Code>
    <env:Value>env:Sender</env:Value>
    <env:Subcode>
     <env:Value>rpc:BadArguments</env:Value>
    </env:Subcode>
   </env:Code>
   <env:Reason>
    <env:Text xml:lang="en-US">Processing error</env:Text>
    <env:Text xml:lang="cs">Chyba zpracování</env:Text>
   </env:Reason>
   <env:Detail>
    <e:myFaultDetails xmlns:e="http://travelcompany.example.org/faults">
     <e:message>Name does not match card number</e:message>
     <e:errorcode>999</e:errorcode>
    </e:myFaultDetails>
   </env:Detail>
  </env:Fault>
 </env:Body>
</env:Envelope>

Processing SOAP

SOAP Operation

Outline (Web Services Description Language (WSDL))

  1. Simple Object Access Protocol (SOAP) [7]
  2. Web Services Description Language (WSDL) [10]
  3. Universal Description, Discovery, and Integration (UDDI) [4]
  4. Conclusions [1]

Describing Web Services

WSDL Data Model

Types

 <wsdl:types>
  <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:GoogleSearch">
   <xsd:complexType name="GoogleSearchResult">
    <xsd:all>
     <xsd:element name="documentFiltering" type="xsd:boolean"/>
     <xsd:element name="searchComments" type="xsd:string"/>
     <xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
     <xsd:element name="estimateIsExact" type="xsd:boolean"/>
     <xsd:element name="resultElements" type="typens:ResultElementArray"/>
     <xsd:element name="searchQuery" type="xsd:string"/>
     <xsd:element name="startIndex" type="xsd:int"/>
     <xsd:element name="endIndex" type="xsd:int"/>
     <xsd:element name="searchTips" type="xsd:string"/>
     <xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
     <xsd:element name="searchTime" type="xsd:double"/>
    </xsd:all>
   </xsd:complexType>

Messages

 <message name="doGoogleSearch">
  <part name="key" type="xsd:string"/>
  <part name="q" type="xsd:string"/>
  <part name="start" type="xsd:int"/>
  <part name="maxResults" type="xsd:int"/>
  <part name="filter" type="xsd:boolean"/>
  <part name="restrict" type="xsd:string"/>
  <part name="safeSearch" type="xsd:boolean"/>
  <part name="lr" type="xsd:string"/>
  <part name="ie" type="xsd:string"/>
  <part name="oe" type="xsd:string"/>
 </message>
 <message name="doGoogleSearchResponse">
  <part name="return" type="typens:GoogleSearchResult"/>
 </message>

Port Types

 <portType name="GoogleSearchPort">
  <operation name="doGetCachedPage">
   <input message="typens:doGetCachedPage"/>
   <output message="typens:doGetCachedPageResponse"/>
  </operation>
  <operation name="doSpellingSuggestion">
   <input message="typens:doSpellingSuggestion"/>
   <output message="typens:doSpellingSuggestionResponse"/>
  </operation>
  <operation name="doGoogleSearch">
   <input message="typens:doGoogleSearch"/>
   <output message="typens:doGoogleSearchResponse"/>
  </operation>
 </portType>

Bindings

 <binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="doGetCachedPage">
   <soap:operation soapAction="urn:GoogleSearchAction"/>
   <input>
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GoogleSearch"/>
   </input>
   <output>
    <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:GoogleSearch"/>
   </output>
  </operation>

Ports

  <port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
   <soap:address location="http://api.google.com/search/beta2"/>
  </port>

Services

 <service name="GoogleSearchService">
  <port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
   <soap:address location="http://api.google.com/search/beta2"/>
  </port>
 </service>

Visualizing WSDL

Locating WSDL Descriptions

Outline (Universal Description, Discovery, and Integration (UDDI))

  1. Simple Object Access Protocol (SOAP) [7]
  2. Web Services Description Language (WSDL) [10]
  3. Universal Description, Discovery, and Integration (UDDI) [4]
  4. Conclusions [1]

WSDL Directory

UDDI Data Model

Mapping WSDL → UDDI

UDDI is a Web Service

Outline (Conclusions)

  1. Simple Object Access Protocol (SOAP) [7]
  2. Web Services Description Language (WSDL) [10]
  3. Universal Description, Discovery, and Integration (UDDI) [4]
  4. Conclusions [1]

Web Services Core Technologies