Beruflich Dokumente
Kultur Dokumente
• Essentials of RESTFUL
Web services
GET http://www.example.com/hello.txt
• HTTP characteristics
– a request-response protocol
– Statelessness
– Scalability
– Addressability
– Cachability
– Unified interface
How the web works?
• HTTP methods (RFC 2616)
Safe Methods Retrieve information
GET retrieve information identified by the Request-URI
HEAD retrieve meta-information information identified by the
Request-URI
Idempotent The result is the same if execute once or many times
Methods
GET, HEAD
PUT store the enclosed entity under the supplied Request-URI
DELETE delete the resource identified by the Request-URI.
WSDL Service 1
WSDL Service 2 Description
Description
Service Registry
UDDI Publish
Find WSDL, UDDI/SOAP WSDL Service 1
WSDL, UDDI/SOAP Description
WSDL Service 2 Publish Service 1
Description WSDL, UDDI/SOAP Service Provider 1
Service Requestor
Service 2
WSDL Service 2
Description
How Big Web Services Works?
• Complex
– Every new layer creates <env:Envelope
failure points, interoperability,
and scalability problems. xmlns:env="http://schemas.xmlsoap.org/soap
– Many SOAP extensions /envelope/">
– Clients need to support <env:Header />
SOAP <env:Body>
<startConference xmlns="http://com/conf">
• No unified interface <str1>alice@ericsson.com</str1>
– Use Remote Procedure Call <str2>bob@ericsson.com</str2>
(RPC) <str3>charles@ericsson.com</str3>
– The method is sent in the </startConference>
SOAP message body </env:Body>
– SOAP messages are sent </env:Envelope>
using HTTP POST
• It is simple
– Uses existing web standards
– The necessary infrastructure has already become pervasive
– RESTFull web services are lightweight
– HTTP traverse firewall
• Resource Oriented
Architecture (ROA)
• Tools
• Examples of existing
RESTFul web services
Resource-Oriented Architecture
• The Resource-Oriented Architecture (ROA)
– Is a RESTful architecture
– Provides a commonsense set of rules for designing
RESTful web services
• ROA concepts
– Resources
– Resources names (Unified Resource Identifiers-URIs)
– Resources representations
– Links between resources
• ROA Properties:
– Addressability
– Statelessness
– Connectedness
– Uniform interface
Resources
• What’s a Resource?
– A resource is any information that
• can be named
• Is important enough to be referenced as a thing in itself
– A resource may be a physical object or an abstract concept
– e.g.
• a document
• a row in a database
• the result of running an algorithm.
• Statelessness
– Makes the protocol simpler
– Ease load balancing
– Ease access to any resource (for client)
• APIs
• HTTP Servlet API
• RestLet
• JSR 311 API for RESTful web service (JAX-RS or Jersey)
• XMLHTTPRequest API
Existing services
• Examples of existing RESTful web services include:
– Amazon’s Simple Storage Service (S3) (http://aws.amazon.com/s3)
2 : 202 A cce pte d(http://w w w . conf e x a mple . com/conf1@ conf e x a mple . com)
3 : INVITE
4 : OK
5 : ACK
6 : 200 O K
8 : 200 O K
Illustrative use case
8. What is supposed to happen?
A lic e C onf A pp Bo b
R E S T C lie n t
R E S T S e rv e r
Add
1 : P O S T (h t t p : //w w w . c o n f e x a m p le . c o m /c o n f 1 @ c o n f e x a m p le . c o m)
participant
< P a r t ic ip a n t s >
< P a r t ic ip a n t m e d ia = “v id e o ”> b o b @ e r ic s s o n . c o m< /P a r t ic ip a n t >
< /P a r t ic ip a n t s >
2 : 2 0 2 A c c e p t e d ()
3 : I N V IT E
4 : OK
5 : ACK
6 : 200 O K
< P a r t ic ip a n t s >
< P a r t ic ip a n t >
< u r i> b o b @ e r ic s s o n . c o m < /u r i>
< lin k> h t t p : //c o n f e x a m p le . c o m /{ c o n f Id } /p a r t ic ip a n t s /b o b @ e r ic s s o n . c o m < /lin k>
< /P a r t ic ip a n t >
< /P a r t ic ip a n t s >
The procedure to create a RESTFul
web service
9. What might go wrong?
– Conference
• JSR 311: JAX-RS: The JavaTM API for RESTful Web Services, online at:
http://jcp.org/en/jsr/detail?id=311