Cover page images (keys)

Reconciling Web Services and REST Services

Hugo Haas <hugo@w3.org>
W3C Web Services Activity Lead

ECOWS 2005, Växjö, Sweden, 15 November 2005

History

Services on the Web

The Web architecture: introducing resources

The Web architecture: interacting with resources

More interactions with resources

What is REST?

Introducing REST services

What are Web services?

SOAP-based Web services

A definition:

A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.

Technologies involved in SOAP-based Web services

Opposition of REST and Web services

Criticisms made by opposed communities

(non-exhaustive lists)

Sounds familiar?

UserFriendly Cartoon for Apr 21, 2005

From UserFriendly.org Copyright © 2005 J.D. "Illiad" Frazer.

  • Editor war: Emacs versus vi
  • Services war: Web services versus REST services
  • Arguments are not dissimilar:
    • vi fans believe that Emacs is bulky and an operating system in itself
    • Emacs fans believe that Emacs is so much more powerful than vi

Another look at the comparison

Finding a non-adversarial view

  1. SOAP-based Web services can be RESTful: there is a vi-mode for Web services
  2. Web services technologies can be useful in the context of non-SOAP-based REST services

A look at the Web services stack

Stack of W3C Web services technologies

Doing SOAP-based Web services in RESTful ways

  1. SOAP-based Web services can be RESTful: there is a vi-mode for Web services
  2. Web services technologies can be useful in the context of non-SOAP-based REST services

SOAP 1.2 in a nutshell

Using SOAP 1.2 in RESTful ways

Weather SOAP-based Web service designed in a non RESTful way

Diagram of a non-RESTful service

Non RESTful service details

Same SOAP-based Web service designed in a RESTful way

RESTful SOAP-based Web service details

RESTful service details

Web services technologies for REST services

  1. SOAP-based Web services can be RESTful: there is a vi-mode for Web services
  2. Web services technologies can be useful in the context of non-SOAP-based REST services
0

Dealing with hyperlinks in REST services

<weather …>
  <temperature>13</temperature>
  <sky>sunny</sky>
  <img xlink:href="http://weather.example/cam/Sweden/V%C3%A4xj%C3%B6?time=0800" />
</weather>

SOAP Message Transmission Optimization Mechanism

MTOM

Using RRSHB for hyperlinks

<soap:Envelope
    xmlns:soap='http://www.w3.org/2003/05/soap-envelope'
    xmlns:rep='http://www.w3.org/2004/08/representation'
    xmlns:xmlmime='http://www.w3.org/2005/05/xmlmime'>
 <soap:Header>
  <rep:Representation 
       resource="http://weather.example/cam/Sweden/V%C3%A4xj%C3%B6?time=0800">
   <rep:Data
   xmlmime:contentType='image/jpeg'>/aWKKapGGyQ=</rep:Data>
  </rep:Representation>
 </soap:Header>
 <soap:Body>
  <weather …>
   <temperature>13</temperature>
   <sky>sunny</sky>
   <img xlink:href="http://weather.example/cam/Sweden/V%C3%A4xj%C3%B6/0800" />
  </weather>
 </soap:Body>
</soap:Envelope>

Then optimize with MTOM

Introducing WSDL 2.0

WSDL 2.0 to describe HTTP services

<binding name="HttpBinding" interface="m:GetTemperature"
         type="http://www.w3.org/2005/08/wsdl/http">
  <operation ref="m:location" whttp:method="GET"
             whttp:location="{country}/{city}"/>
</binding>

allows for an HTTP GET on http://weather.example/Sweden/V%C3%A4xj%C3%B6:

HTTP/1.1 200 Here's the temperature for you
Content-Type: application/xml
…

<weather xmlns="…">
  <temperature>23</temperature>
</weather>

WSDL 2.0 HTTP binding

<interface name="Maintenance">
  <operation name="weather">
    <input messageLabel="In" element="s:weather"/>
    <output messageLabel="Out" element="#none"/>
  </operation>
  <operation name="DelCity">
    <input messageLabel="In" element="s:City"/>
    <output messageLabel="Out" element="#none"/>
  </operation>
</interface>

<binding name="HttpBindng" interface="m:Maintenance"         
         type="http://www.w3.org/2005/08/wsdl/http">
  <operation ref="m:weather" whttp:method="PUT"
             whttp:location="{country}/{city}"/>
  <operation ref="m:DelCity" whttp:method="DELETE"
             whttp:location="{country}/{city}"/>
</binding>

<service>
  <endpoint name="AdminEndpoint" binding="m:HttpBinding"
            whttp:authenticationType="digest"
            whttp:realm="admin"
            address="http://ws.accurateweather.example/"/>
</service>

Messages from example REST service: PUT

HTTP PUT to upload new data

PUT /Sweden/V%C3%A4xj%C3%B6 HTTP/1.1
Host: ws.accurateweather.example
Authorization: Digest username="hugo",
        realm="admin",
        nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
        uri="/Sweden/V%C3%A4xj%C3%B6",
        …
Content-Type: application/xml
…

<weather xmlns="…">
  <temperature>23</temperature>
</weather>

with a response:

HTTP/1.1 204 Resource updated

Messages from example REST service: DELETE

HTTP DELETE to erase a city

DELETE /Sweden/V%C3%A4xj%C3%B6 HTTP/1.1
Host: ws.accurateweather.example
Authorization: Digest username="hugo",
        realm="admin",
        nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093",
        uri="/Sweden/V%C3%A4xj%C3%B6",
        …
    

with a response:

HTTP/1.1 204 City deleted

WS-CDL 1.0

Example of a WS-CDL description

Example of a collaboration describable with WS-CDL 1.0

Upcoming areas of common interest

Reconciling the communities

References