Web Services, for DevDays Belfast
-
Upload
chrismcclelland -
Category
Technology
-
view
1.632 -
download
1
description
Transcript of Web Services, for DevDays Belfast
Web ServicesChris McClelland
DevDays, Belfast April 2009
About
Specialising in Mobile Strategy, Development, Design and Usability.
New and rapidly developing company based in Belfast, presently 4 people, but more to come!
Established Jan 2009.
WEB APP
APIrequest
data
Web Services?
iPhone
“machine”
WEB APP
API
Why?
Outsource - community development
Growth
Novel Use of Data
Google Maps
Success Stories
Last.fm
Ebay
iPhone Developers Why?
free content
large existing user-base
mashups
@stroughtonsmith
REST vs SOAP
SOAP
SOAPSimple Object Access Protocol
XML
XML to code and to decode dataSOAP to transport it
RESTREpresentational State Transfer
HTTP verbs:
GET: Retrieves a resource
POST: Sends data to create a resource
PUT: Sends data to update a resource
DELETE: Destroys a resource
stateless
just HTTP + URIs
SOAPPOST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice></soap:Body>
</soap:Envelope>
XML (Extensible Markup Language)
REST
GET www.example.org/user/2
POST /user
GET /user/1
PUT /user/1
DELETE /user/1
RESTful
POST /user/create
GET /user/show/1
POST /user/update/1
POST/GET /user/delete/1
NOT RESTful
methods URI
SOAPHTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse></soap:Body>
</soap:Envelope>
REST
<contacts page="1" pages="1" perpage="1000" total="3"> <contact nsid="12037949629@N01"
username="Eric" iconserver="1"realname="Eric Costello"friend="1" family="0" ignored="1" />
<contact nsid="12037949631@N01" username="neb" iconserver="1"realname="Ben Cerveny"friend="0" family="0" ignored="0" />
<contact nsid="41578656547@N01" username="cal_abc" iconserver="1"realname="Cal Henderson"friend="1" family="1" ignored="0" />
</contacts>
http://api.flickr.com/services/rest/?method=flickr.contacts.getList&api_key=XXX&api_sig=XXX
request
data
XML
JSON
RSS, Atom
Other e.g. PNG, Microformats
REST - data received
RSS
SOAP - benefits
WS-*
offers options for Privacy, Transfer, Eventing, Addressing, Notification, ReliableMessaging
Mature
Enterprise
REST Authentication
OAuth“An open protocol to allow secure API authorisation in a simple and standard method from desktop and web applications.”
done via HTTPS
to avoid giving the application / developer your username and password:
http://www.flickr.com/photos/factoryjoe/
http://www.flickr.com/photos/factoryjoe/
http://www.flickr.com/photos/factoryjoe/
REST - benefits
Simple
Popular, very Web 2.0
Better performance & scalability
Can be cached
Allows diverse formats e.g. JSON
Built into many web frameworks
Easier in Objective-C
HTTP - ASIHTTPRequest
XML, Microformats, RSS, Atom - NSXMLParser, libxml
JSON - json-framework
Rails - ObjectiveResource
SOAP - wsdl2objc
OAuth - MPOAuthConnection
iPhone Libraries
All Yahoo: flickr
myspace, virb, facebook
delicious
Amazon Web Services, SimpleDB
vimeo, youtube
ebay
RESTful APIs
Thanks!
@chrismcclelland
www.ecliptic-design.com