Slides for Lia's talk

hungryhorsecabinSoftware and s/w Development

Dec 14, 2013 (3 years and 7 months ago)

88 views

Programming for Web Services,
Service Oriented Architecture(SOA):
SOAP vs. REST
Lia Qu
April 9th, 2013
1
Friday, April 26, 13
Table of Content

Web Service

SOAP

REST

CityStory - A web service portal

Programming Example - US Census Bureau
2
Friday, April 26, 13
Why Web Services is so important?
3
Friday, April 26, 13
Why Web Services is so important?

Reason 1: Reusing functionality
of already developed system in
new softwares

Reason 2: Facilitates the
development of heterogeneous
distributed applications

Reason 3: Accessibility of
applications through firewalls
using web protocols.
3
Friday, April 26, 13
4
Friday, April 26, 13
function1()
function2()
...
Call function()...
4
Friday, April 26, 13
Web Service is a way of establishing
communication between two softwares
Server(Service Provider)
Client(Service Consumer)
function1()
function2()
...
Call function()...
4
Friday, April 26, 13
Server(Service Provider)
Client(Service Consumer)
Call function()...
Web Service Communication Condition
5
Friday, April 26, 13
Server(Service Provider)
Client(Service Consumer)
Call function()...

Do not need to use the
same programming
language

Do no need be on the
same machine
Web Service Communication Condition
Don’t need
5
Friday, April 26, 13
Server(Service Provider)
Client(Service Consumer)
Call function()...

Do not need to use the
same programming
language

Do no need be on the
same machine
Web Service Communication Condition

Must have network connect
to these two softwares
(Internet using HTTP)

Must follow format of I/O
messages (SOAP)
Don’t need
Need
5
Friday, April 26, 13
Server(Service Provider)
Client(Service Consumer)
Call function()...
Simple Object Access Protocol (SOAP)
Address & Description
6
Friday, April 26, 13

Functions this web services offer

Signature of each function

Standard and protocols used by this web service
Server(Service Provider)
Client(Service Consumer)
Call function()...
Simple Object Access Protocol (SOAP)
XML(WSDL)
Address & Description
6
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
7
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
1. XML(WSDL)
7
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
1. XML(WSDL)
Access web service
7
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
8
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
UDDI
2. XML(WSDL)
8
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
UDDI
2. XML(WSDL)
8
Friday, April 26, 13
How to locate XML(WSDL) on Internet?
Server(Service Provider)
Client(Service Consumer)
UDDI
2. XML(WSDL)
Access web service
8
Friday, April 26, 13

REST is an architectural style. Any software
adhering with the definition of REST would
be considered as REST based.

RESTful Web Services are the one that
supports REST concept.
Representational State Transfer(REST)
9
Friday, April 26, 13
RESTful Web Service
RESTful Server
Client
10
Friday, April 26, 13
RESTful Web Service
RESTful Server
Client
Resource
...
(in format of HTML, XML,
JSON, image.etc)
10
Friday, April 26, 13
RESTful Web Service
RESTful Server
Client
send a request via URIs
Resource
...
(in format of HTML, XML,
JSON, image.etc)
10
Friday, April 26, 13
RESTful Web Service
RESTful Server
Client
send a request via URIs
Resource
...
(in format of HTML, XML,
JSON, image.etc)
response  representation of resource
10
Friday, April 26, 13
HTTP is a stateless communication protocol, which
best describes RESTful web service
RESTful Server
Client
send a request via URI
11
Friday, April 26, 13
HTTP is a stateless communication protocol, which
best describes RESTful web service
RESTful Server
Client
send a request via URI
Uniform interface:
GET: retrieve a resource
POST: create a resource
PUT: update a resource
DELETE: delete a resource
11
Friday, April 26, 13
SOAP vs REST
SOAP
REST
Definition
protocol
architecture style
Service provided
function()
resources
The way to access
service
XML(WSDL)
URI (URL, URN)
Interface
No uniform
operation
Http
(GET, POST...)
Security
require contextual
information, and
communication stated
stateless;
used in the presence of
firewall
12
Friday, April 26, 13
Use SOAP or REST?
(SOAP)
13
Friday, April 26, 13
Use SOAP or REST?

A formal contract must be established to describe the
interface that the web service offer.

The architecture must address complex nonfunctional
requirements that go beyond simple CRUD operations and
require contextual information and conversational state to
be maintained.

The application need to handle asynchronous processing
and invocation?

The bandwidth issue is particular important?

Easy aggregation and deployment to existing application are
important to you?
(SOAP)
13
Friday, April 26, 13
Use SOAP or REST?

A formal contract must be established to describe the
interface that the web service offer.

The architecture must address complex nonfunctional
requirements that go beyond simple CRUD operations and
require contextual information and conversational state to
be maintained.

The application need to handle asynchronous processing
and invocation?

The bandwidth issue is particular important?

Easy aggregation and deployment to existing application are
important to you?
(SOAP)
(SOAP)
(SOAP)
(REST)
(SOAP)
(REST)
13
Friday, April 26, 13
14
Friday, April 26, 13
CityStory
http://citystory.herokuapp.com
14
Friday, April 26, 13
Example - US Census Bureau APIs
15
Friday, April 26, 13
Example - US Census Bureau APIs
16
Friday, April 26, 13
Example - US Census Bureau APIs
Required parameter:
- stateCode
- cityCode
- population data
16
Friday, April 26, 13
Example - US Census Bureau APIs
Step by Step guide:
1.
Request a Key
2.
Access a resource through
a URL
3.
Query response as a JSON
array
4.
Organize response in Java
5.
Visualize it by Google
Chart APIs
Required parameter:
- stateCode
- cityCode
- population data
16
Friday, April 26, 13
Example - US Census Bureau APIs
1.
Request a Key
(Example of the request URL for 2010 Census SF1
data that has an assigned key inserted.)
17
Friday, April 26, 13
Example - US Census Bureau APIs
2.
Accessing data through URL
Type URL in browser’s address:
http://api.census.gov/data/2010/sf1?
key=24c30d6fdf727e050333f2a5f9f6a864a2ff
7b4a&get=NAME&for=state:*
18
Friday, April 26, 13
Example - US Census Bureau APIs
3.
Connect to web service
19
Friday, April 26, 13
Example - US Census Bureau APIs
4.
Query response as a JSON array
20
Friday, April 26, 13
Example - US Census Bureau APIs
4.
Query response as a JSON array
stateCode


cityCode


20
Friday, April 26, 13
Example - US Census Bureau APIs
4.
Query response as a JSON array
stateCode


cityCode


population data....

20
Friday, April 26, 13
Example - US Census Bureau APIs
21
Friday, April 26, 13
Example - US Census Bureau APIs
- get population of a city. Group the population data
by Sex and Age.
22
Friday, April 26, 13
Example - US Census Bureau APIs
- get population of a city. Group the population data
by Sex and Age.
In Controller:
23
Friday, April 26, 13
Example - US Census Bureau APIs
5.
Visualize it by Google Chart APIs
Check the JSON format at:
http://citystory.herokuapp.com/population/pennsylvania/pittsburgh
24
Friday, April 26, 13
Questions?
Thank you!
25
Friday, April 26, 13