32
Chanaka Fernando Technical Lead Ishan Jayawardena Senior Software Engineer May 29 2014 RESTful Integration with WSO2 ESB

Restful Integration with WSO2 ESB

  • Upload
    wso2

  • View
    903

  • Download
    3

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Restful Integration with WSO2 ESB

Chanaka FernandoTechnical Lead

Ishan JayawardenaSenior Software Engineer

May 29 2014

RESTful Integration with WSO2 ESB

Page 2: Restful Integration with WSO2 ESB

About the Presenters

๏ Chanaka Fernando - [email protected]

Chanaka joined WSO2 in January 2013. He is a Technical Lead in the WSO2 Enterprise Service Bus team. In addition to his product development efforts he has also provided technology consulting on customer engagements, including customer QuickStart programs. Chanaka has also published numerous articles on WSO2 products which are available in the WSO2 library.

๏ Ishan Jayawardena - [email protected]

Ishan is a Senior Software Engineer in the integration technologies team where he mainly focuses on the WSO2 Enterprise Service Bus. In addition to his product development efforts he has also provided technology consulting on customer engagements, including customer QuickStart programs focused on Enterprise Application Integration projects.

Page 3: Restful Integration with WSO2 ESB

About WSO2

๏ Global enterprise, founded in 2005 by acknowledged leaders in XML, web services technologies, standards and open source

๏ Provides only open source platform-as-a-service for private, public and hybrid cloud deployments

๏ All WSO2 products are 100% open source and released under the Apache License Version 2.0.

๏ Is an Active Member of OASIS, Cloud Security Alliance, OSGi Alliance, AMQP Working Group, OpenID Foundation and W3C.

๏ Driven by Innovation

๏ Launched first open source API Management solution in 2012

๏ Launched App Factory in 2Q 2013

๏ Launched Enterprise Store and first open source Mobile solution in 4Q 2013

Page 4: Restful Integration with WSO2 ESB

What WSO2 delivers

Page 5: Restful Integration with WSO2 ESB

Agenda

๏ What is WSO2 Enterprise Service Bus (ESB)

๏ The importance of REST

๏ Configuring REST APIs and resources with WSO2 ESB

๏ Extended JSON support for RESTful integrations

๏ Designing APIs with uri-templates and url-mapping techniques

๏ Use Case : Pizza Shop

Page 6: Restful Integration with WSO2 ESB

*

WSO2 Enterprise Service Bus

๏ A lightweight, high performance ESB

๏ Comprehensive REST, SOAP, WS-* support

๏ 100% compliant with all EIPs (Enterprise Integration Patterns)

๏ Connectors (Salesforce, Twilio and many more)

๏ SAP, FIX, HL7 - Domain specific solutions

๏ Zero Code/Configuration driven

๏ Extensible and Scalable

Page 7: Restful Integration with WSO2 ESB

WSO2 Enterprise Service Bus

๏ Under the hood: Apache Synapse

๏ A lightweight, open source ESB implementation from the ASF :http:

//synapse.apache.org

๏ Makes up the mediation engine of WSO2 ESB

๏ Multithreaded and asynchronous message processing core

๏ Based on a number of well known open source projects (eg: Axis2, Http Core)

Page 8: Restful Integration with WSO2 ESB

What is REST?๏ REpresentational State Transfer ๏ An architectural Style – Not a Standard ๏ REST uses HTTP for CRUD (Create/Read/Update/Delete) operations๏ RESTful applications use HTTP requests to

• post data (create and/or update) • read data (e.g., make queries) • Delete data.

Page 9: Restful Integration with WSO2 ESB

Trend towards REST

๏ Amazon AWS (Over 90% of the clients use RESTful API)

๏ Google Maps

๏ Yahoo

๏ Ebay

๏ Twitter

Page 10: Restful Integration with WSO2 ESB

ESB REST APIs

๏ Similar to a web application hosted on the ESB

๏ Anchored at a specific URL path (context)

๏ Eg: /news

๏ Can be bound to a specific hostname:port

๏ Contains one or more Resources

Page 11: Restful Integration with WSO2 ESB

ESB REST APIs

๏ Exposes RESTful APIs

๏ REST → SOAP conversion

๏ SOAP → REST conversion

๏ REST → REST conversion

Page 12: Restful Integration with WSO2 ESB

ESB REST APIs

๏ Creating a REST API...

Page 13: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

๏ A RESTful resource exposed over HTTP

Eg: /news/latest

๏ Similar to a proxy service but focuses on REST

๏ Can be associated with

๏ A set of HTTP verbs

๏ A specific content type

๏ A particular class of clients (user agents)

Page 14: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

๏ URL Patterns

๏ Regex match (/news/*)

๏ Extension match (*.jsp)

๏ Exact match (/news/index.jsp)

๏ URI templates

๏ /dictionary/{char}/{word}

๏ HTTP verbs (GET/POST/PUT/DELETE)

๏ A set of HTTP verbs

๏ A specific content type

๏ A particular class of clients (user agents)

Page 15: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

Page 16: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

/people

Page 17: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

/people

GET/staff/*

Page 18: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

/people

GET/staff/*

POST/add?name={name}&id={id}

Page 19: Restful Integration with WSO2 ESB

ESB REST APIs : Resources

Page 20: Restful Integration with WSO2 ESB

HTTPEndpoint<endpoint xmlns="http://ws.apache.org/ns/synapse" name="HTTPEndpoint"> <http

uri-template="http://localhost:8080/{uri.var.companyname}/restapi/{uri.var.servicename}/menu?category={uri.var.category}"

method="GET"> </http></endpoint>

Sample request:

http://localhost:8280/pizza?

companyname=wso2&servicename=lunch&category=vegetable

Page 21: Restful Integration with WSO2 ESB

๏ Data Formats plays a major role in REST integrations

๏ Easy to transform between JSON and XML

๏ Native JSON support for handling JSON only scenarios like mobile applications

๏ Directly evaluate json message rather than converting to XML

Eg: <filter source="json-eval(pizza.name)" regex="Meat Sizzler">

JSON Support for REST

Page 22: Restful Integration with WSO2 ESB

Use Case : Pizza Shop

Page 23: Restful Integration with WSO2 ESB

API - /pizzashop

Resources

๏ Pizza - /api/menu/pizza* [GET]๏ Order - /api/order* [POST]๏ Order - /api/order/{orderId} [POST, GET, DELETE, PUT]๏ Purchase - /api/purchase/{orderId} [POST]

Use Case : Pizza Shop

Page 24: Restful Integration with WSO2 ESB

<resource methods="GET" uri-template="/api/menu/pizza*"> <inSequence> ....................... </inSequence> <outSequence> ....................... </outSequence> </resource>sample requestshttp://127.0.0.1:8280/pizzashop/api/menu/pizzahttp://127.0.0.1:8280/pizzashop/api/menu/pizza?val=thin&type=crust

Use Case : Pizza Shop

Page 25: Restful Integration with WSO2 ESB

<resource methods="POST" uri-template="/api/order*"> <inSequence> ..................... </inSequence> <outSequence> ..................... </outSequence> </resource> sample requestshttp://127.0.0.1:8280/pizzashop/api/order{"order": { "items": [ {"id": 1, "qty": 2}, {"id": 2, "qty": 1} ]}}

Use Case : Pizza Shop

Page 26: Restful Integration with WSO2 ESB

<resource methods="POST GET DELETE PUT" uri-template="/api/order/{orderId}"> <inSequence> ...................... </inSequence> <outSequence> ...................... </outSequence> </resource>

sample requestshttp://127.0.0.1:8280/pizzashop/api/order/0001

Use Case : Pizza Shop

Page 27: Restful Integration with WSO2 ESB

<resource methods="POST" uri-template="/api/purchase/{orderId}"> <inSequence> .............. </inSequence> <outSequence> ................ </outSequence> </resource> sample requestshttp://127.0.0.1:8280/pizzashop/api/purchase/0001{“purchaseInformation”:

{ “amount”: 175.00, “cc”: "1234-5678-9876-5432"

}}

Use Case : Pizza Shop

Page 28: Restful Integration with WSO2 ESB

Complete samplehttp://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/

Use Case : Pizza Shop

Page 29: Restful Integration with WSO2 ESB

Questions?

Page 31: Restful Integration with WSO2 ESB

**

Business Model

Page 32: Restful Integration with WSO2 ESB

Contact us !