Introduction

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST Architectural Style: A Detail Explain
Cao Duc Nguyen nguyen.cao-duc@hp.com
Software Designer

December 12, 2011

Introduction

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Outline Introduction Web APIs REST Fundamentals HTTP REST Java Open Source RESTful Web Services Specification Implementation Conclusion Discussion Final word

1

2

3

4

Introduction Web APIs

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

The Importance of APIs in Web Development

Introduction Web APIs

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

APIs Timeline on ProgrammableWeb

Introduction Web APIs

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

APIs Timeline on ProgrammableWeb in more details

Introduction Web APIs

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Featured APIs & Mashups

Introduction Web APIs

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

APIs protocols & styles

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST is an architectural style Gorthic Architectural Style

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST v.s HTTP

Gorthic architectural style

REST

HTTP

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Client/Server Model

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

HTTP is resource-centric

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Resource Identifier, Methods & Representations

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Hypermedia: Association & Composition

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

HTTP Methods in more details GET PUT DELETE HEAD OPTIONS POST Safe The client did not request any side-effects on server other than data retrieval. Idempotent Any side-effects on the server of several identical idempotent methods are the same as the side-effects of one single method. Cacheable Explain in more details later. . . Safe, Idempotent, Cacheable Idempotent Idempotent Safe, Idempotent Safe, Idempotent

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Intermediaries - Cache A new request for a cached resource can be returned immediately by intermediary caches.

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Intermediaries - Proxy & Gateway

Proxy an intermediary selected by a client, to provide interfaces to services like data translation, performance enhancement, or security protection. Gateway an intermediary imposed by the network or origin server to provide an interface encapsulation of other services, for data translation, performance enhancement, or security enforcement.

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Stateless

HTTP Requests are stateless, which means each request is independent from the others.

Introduction HTTP

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Stateless

HTTP Requests are stateless, which means each request is independent from the others. intermediaries only need to work on a single interaction without knowing the entire topology

Introduction REST

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST Architectural Style

REpresentational State Transfer The representation returned by the server places or transfers the client from state to state. REST Architectural Style . . . a set of architectural constraints that, when applied as a whole, emphasizes scalability of component interactions, generality of interfaces, independent deployment of components, intermediary components to reduce interaction latency, enforce security, and encapsulate legacy systems. Roy T. Fielding

Introduction REST

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST Architectural Constraints

Introduction REST

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST Architectural Elements

Introduction REST

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

RESTful v.s SOAP

Introduction Specification

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

JAX-RS: The Java™API for RESTful Web Services

Introduction Specification

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

JAX-RS Hello Example import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @Path("/hello/{username}") public class Hello { private String name="no-one"; @GET @Produces("text/plain") public String hello(@PathParam("username") String userName) { userName = userName==null?name:userName; return " Hello, "+userName; }

Introduction Specification

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

JAX-RS Hello Example

@POST @Consumes("text/plain") public String hello(@FormParam("username") String userName) { name = userName==null?name:userName; return " Hello, "+userName; } }

Introduction Implementation

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Open Sources RESTful Web Service Implementation of JAX-RS

Jersey - Sun reference implementation RESTEasy - JBoss Restlet

Introduction Discussion

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST Motivation

Scalability Perfomance Reduce Payload & Latency Dynamic Component Connectors

Introduction Discussion

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

REST v.s the rest

SOA ? Servlet & JSP ? Javascript ?

Introduction Final word

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Web APIs Worldwide

Introduction Final word

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Web APIs Featured Regions

Introduction Final word

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

Web APIs Vietnam

Introduction Final word

REST Fundamentals

Java Open Source RESTful Web Services

Conclusion

THANK YOU *-*