REST & API Management with the WSO2 ESB

44
 REST and API Management with Hiranya Jayathilaka Product Manager – WSO2 ESB

Transcript of REST & API Management with the WSO2 ESB

Page 1: REST & API Management with the WSO2 ESB

   

REST and API Managementwith

Hiranya JayathilakaProduct Manager – WSO2 ESB

Page 2: REST & API Management with the WSO2 ESB

   

What is REST?

● REpresentational State Transfer● Lightweight, Client­Server architecture● Interactions are based on the transfer of 

resource state representations● Systems exchange state representations and 

perform application state transitions● Mostly implemented using HTTP but can be 

based on other protocols

Page 3: REST & API Management with the WSO2 ESB

   

Origin and Growth

● First introduced by Roy Fielding in his doctoral dissertation

● Developed in parallel with HTTP/1.1● WWW is the largest known implementation of a 

RESTful architecture● Widely used in modern days as an alternative to 

technologies like CORBA and SOAP

Page 4: REST & API Management with the WSO2 ESB

   

REST By Example...

● Learning Management System for a school● A number of fundamental concepts

● Student● Course● Teacher

● In a RESTful design these concepts are likely to become the 'resources' managed by the LMS

Page 5: REST & API Management with the WSO2 ESB

   

The 'Student' Resource State

● Name● Index number● Age● Date of birth● Contact information● GPA● ...

Page 6: REST & API Management with the WSO2 ESB

   

State Representation ­ XML

Page 7: REST & API Management with the WSO2 ESB

   

State Representation ­ JSON

Page 8: REST & API Management with the WSO2 ESB

   

Application State

● Applications have states● Number of students in the system● Number of associations between students and 

courses● Number of teachers

● Application state transitions may occur as a result of a resource state transfer

● Application state can also be represented using some data format or hyper text references

Page 9: REST & API Management with the WSO2 ESB

   

Representational State Transfer

● Clients and servers interact with each other by exchanging ● Resource state representations● Application state representations● Other control information

Page 10: REST & API Management with the WSO2 ESB

   

RESTful Interactions

Page 11: REST & API Management with the WSO2 ESB

   

Why HTTP?

● Rich vocabulary and powerful tools that are ideal for representing resource states, application states and control data● Application state – Status code + Links● Resource state – HTTP entity● Control data – HTTP method

● CRUD operations map nicely into HTTP methods

Page 12: REST & API Management with the WSO2 ESB

   

HTTP Based RESTful Interactions

Page 13: REST & API Management with the WSO2 ESB

   

Advantages

● Simple and lightweight● Easy to implement● Very little processing at the application level● Small amount of data to pass around

● Support any content type● Leverage built­in application layer protocol 

semantics without reinventing the wheel

Page 14: REST & API Management with the WSO2 ESB

   

Notable Deployments

● Amazon AWS (Over 90% of the clients are using the RESTful API)

● Google Maps● Yahoo!● eBay

● Sastry Malladi on service orientation ­ http://www.youtube.com/watch?v=O­9osZGXDok

Page 15: REST & API Management with the WSO2 ESB

   

WSO2 ESB

● A lightweight, high­performance ESB● Feature rich and standards compliant

● SOAP and WS­* standards● REST support● Variety of protocols and message formats

● User friendly and highly extensible● 100% free and open source with commercial 

support

Page 16: REST & API Management with the WSO2 ESB

   

Under the Hood

● WSO2 ESB is based on a number of well known Apache projects● Synapse ­ http://synapse.apache.org● Axis2­ http://axis.apache.org/axis2/java/core● Web Services ­ http://ws.apache.org

● REST support of WSO2 ESB stems from the REST support offered by Axis2

Page 17: REST & API Management with the WSO2 ESB

   

REST Support in Axis2

● Axis2 provides a REST binding for each deployed web service

● This enables clients to invoke any Axis2 service via REST calls● GET /services/HelloService/sayHello● GET /services/MathService/add?a=5&b=10

Page 18: REST & API Management with the WSO2 ESB

   

REST Support in WSO2 ESB

● WSO2 ESB can receive and mediate REST calls just like any other request

● The same mediators that work with SOAP can be used to manipulate REST invocations● Log, Send, Filter, Switch, XSLT, DBLookup....

● Additional handles provided by the ESB in the form of properties

● Easily switch between SOAP and REST

Page 19: REST & API Management with the WSO2 ESB

   

Exposing a SOAP Service via REST

Page 20: REST & API Management with the WSO2 ESB

   

Sample Proxy Configuration

Page 21: REST & API Management with the WSO2 ESB

   

Exposing a REST/POX Service via SOAP

Page 22: REST & API Management with the WSO2 ESB

   

Sample Proxy Configuration

Page 23: REST & API Management with the WSO2 ESB

   

Exercising More Control Over REST

● Manipulate REST calls based on● HTTP method● Status code● Content type● HTTP headers

Page 24: REST & API Management with the WSO2 ESB

   

Accessing HTTP Method

Page 25: REST & API Management with the WSO2 ESB

   

Examples

Page 26: REST & API Management with the WSO2 ESB

   

Accessing HTTP Status Codes

Page 27: REST & API Management with the WSO2 ESB

   

Examples

Page 28: REST & API Management with the WSO2 ESB

   

Manipulating HTTP Headers

Page 29: REST & API Management with the WSO2 ESB

   

Examples

Page 30: REST & API Management with the WSO2 ESB

   

REST APIs

● An API is similar to a web application hosted on the ESB

● Anchored at a specific URL path (context)● /test● /dictionary● /foo/bar

● Can be bound to a specific host and a port● Contains one or more resources

Page 31: REST & API Management with the WSO2 ESB

   

Resources

● A RESTful resource exposed over HTTP● Similar to a proxy service but focuses on REST● Can be associated with

● A set of HTTP methods– GET only, GET and POST only, All HTTP methods

● A specific content type– application/xml, application/json

● A particular class of clients (user agents)

Page 32: REST & API Management with the WSO2 ESB

   

Dispatching Requests to a Resource

● URL patterns● Reg­Ex match (/test/*)● Extension match (*.jsp)● Exact match (/test/index.jsp)

● URI templates● /dictionary/{character}/{word}● /accounts/{accountId}/{operation}

Page 33: REST & API Management with the WSO2 ESB

   

APIs and Resources

Page 34: REST & API Management with the WSO2 ESB

   

Resource Examples

Page 35: REST & API Management with the WSO2 ESB

   

API Example

Page 36: REST & API Management with the WSO2 ESB

   

APIs in Action

Page 37: REST & API Management with the WSO2 ESB

   

API Management Goals

● Service provider objectives● Define APIs● Define security requirements and SLAs● Monitor API usage and SLAs

● Service consumer objectives● Discover and browse APIs● Sign up and obtain API keys● Consume APIs using the obtained keys● Monitor API usage and SLAs

Page 38: REST & API Management with the WSO2 ESB

   

Solution Architecture

Page 39: REST & API Management with the WSO2 ESB

   

WSO2 Product Mapping

Page 40: REST & API Management with the WSO2 ESB

   

Summary and Recap

● REST is a lightweight, client­server architecture for building distributed systems

● RESTful designs are concerned with resources, states and transfer of representational state between systems

● WSO2 ESB provides excellent support for receiving, processing and intermediating REST (HTTP) calls

● The new API concept is a powerful feature which allows developers to define REST APIs in the ESB without writing any additional code

● WSO2 platform is ideally suited for developing comprehensive and flexible API management solutions based on open standards

Page 41: REST & API Management with the WSO2 ESB

   

Questions?

Page 42: REST & API Management with the WSO2 ESB

   

Selected Customers

Page 43: REST & API Management with the WSO2 ESB

   

WSO2 Engagement Model

● Quick Start● Development Support● Development Services● Production Support● Turnkey Solutions

● WSO2 Mobile Services Solution● WSO2 FIX Gateway Solution● WSO2 SAP Gateway Solution

Page 44: REST & API Management with the WSO2 ESB

   

Thank You