Hugo Haas <[email protected]>
W3C Web
Services Activity Lead
ECOWS 2005, Växjö, Sweden, 15 November 2005
http://www.w3.org/
http://ヒキワリ.ナットウ.ニホン.example/
title
element whose content is World Wide Web Consortium, etc.
GET
) has interesting properties:
POST
: process messagePUT
: update representationDELETE
: delete resourceGET
, POST
,
PUT
, DELETE
XMLHttpRequest
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.
POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "Some-URI" <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:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
http://stockquoteserver.example/query?symbol=DIS
(non-exhaustive lists)
From UserFriendly.org Copyright © 2005 J.D. "Illiad" Frazer.
vi-mode
for Web servicesvi-mode
for Web serviceshttp://weather.example/endpoint
HTTP POST
in,
SOAP out):
GetWeather
: get the current weather at a cityAddCity
: add a city to the systemSetWeather
: set weather information for a cityDelCity:
delete a city from the systemGetWeather
:
POST /endpoint HTTP/1.1 Host: weather.example Content-Type: application/soap+xml Content-Length: 251 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> <w:GetWeather xmlns:w="http://weather.example/"> <w:city>Växjö</w:city> <w:country>Sweden</w:country> </w:GetWeather> </env:Body> </env:Envelope>
A simple "get" operation should be done with HTTP GET
http://weather.example/country/city
GET http://weather.example/country/city
: get the
current weather at a cityPOST http://weather.example/country/city
:
set weather information for a cityDELETE http://weather.example/country/city
: delete a
city from the systemPOST http://weather.example/addCity
: add a city to the
systemGET
:
GET /Sweden/V%C3%A4xj%C3%B6 HTTP/1.1 Host: weather.example Accept: application/soap+xml
vi-mode
for Web 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: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
<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>
<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>
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
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
After all, the editor war has been going on for decades