web services, for devdays belfast

25
Web Services Chris McClelland DevDays, Belfast April 2009 [email protected]

Upload: chrismcclelland

Post on 15-Jan-2015

1.629 views

Category:

Technology


1 download

DESCRIPTION

Introduction to WebServices, Rest, SOAP, XML, iPhone

TRANSCRIPT

Page 1: Web Services, for DevDays Belfast

Web ServicesChris McClelland

DevDays, Belfast April 2009

[email protected]

Page 2: Web Services, for DevDays Belfast

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.

Page 3: Web Services, for DevDays Belfast

WEB APP

APIrequest

data

Web Services?

iPhone

“machine”

Page 4: Web Services, for DevDays Belfast

WEB APP

API

Why?

Outsource - community development

Growth

Novel Use of Data

Page 5: Web Services, for DevDays Belfast

Google Maps

Success Stories

Last.fm

Ebay

Facebook

Twitter

Page 6: Web Services, for DevDays Belfast

iPhone Developers Why?

free content

large existing user-base

mashups

Page 7: Web Services, for DevDays Belfast

@stroughtonsmith

Page 8: Web Services, for DevDays Belfast

REST vs SOAP

Page 9: Web Services, for DevDays Belfast

SOAP

SOAPSimple Object Access Protocol

XML

XML to code and to decode dataSOAP to transport it

Page 10: Web Services, for DevDays Belfast

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

Page 11: Web Services, for DevDays Belfast

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)

Page 13: Web Services, for DevDays Belfast

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

Page 14: Web Services, for DevDays Belfast

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>

Page 15: Web Services, for DevDays Belfast

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

Page 16: Web Services, for DevDays Belfast

XML

JSON

RSS, Atom

PDF

Other e.g. PNG, Microformats

REST - data received

RSS

Page 17: Web Services, for DevDays Belfast

SOAP - benefits

WS-*

offers options for Privacy, Transfer, Eventing, Addressing, Notification, ReliableMessaging

Mature

Enterprise

Page 18: Web Services, for DevDays Belfast

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:

Page 22: Web Services, for DevDays Belfast

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

Page 24: Web Services, for DevDays Belfast

All Yahoo: flickr

myspace, virb, facebook

delicious

Amazon Web Services, SimpleDB

vimeo, youtube

ebay

google

RESTful APIs

Page 25: Web Services, for DevDays Belfast

Thanks!

@chrismcclelland

[email protected]

www.ecliptic-design.com