Download - Restful Integration with WSO2 ESB
![Page 1: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/1.jpg)
Chanaka FernandoTechnical Lead
Ishan JayawardenaSenior Software Engineer
May 29 2014
RESTful Integration with WSO2 ESB
![Page 2: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/2.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/3.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/4.jpg)
What WSO2 delivers
![Page 5: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/5.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/6.jpg)
*
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/7.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/8.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/9.jpg)
Trend towards REST
๏ Amazon AWS (Over 90% of the clients use RESTful API)
๏ Google Maps
๏ Yahoo
๏ Ebay
![Page 10: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/10.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/11.jpg)
ESB REST APIs
๏ Exposes RESTful APIs
๏ REST → SOAP conversion
๏ SOAP → REST conversion
๏ REST → REST conversion
![Page 12: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/12.jpg)
ESB REST APIs
๏ Creating a REST API...
![Page 13: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/13.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/14.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/15.jpg)
ESB REST APIs : Resources
![Page 16: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/16.jpg)
ESB REST APIs : Resources
/people
![Page 17: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/17.jpg)
ESB REST APIs : Resources
/people
GET/staff/*
![Page 18: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/18.jpg)
ESB REST APIs : Resources
/people
GET/staff/*
POST/add?name={name}&id={id}
![Page 19: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/19.jpg)
ESB REST APIs : Resources
![Page 20: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/20.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/21.jpg)
๏ 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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/22.jpg)
Use Case : Pizza Shop
![Page 23: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/23.jpg)
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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/24.jpg)
<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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/25.jpg)
<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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/26.jpg)
<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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/27.jpg)
<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](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/28.jpg)
Complete samplehttp://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/
Use Case : Pizza Shop
![Page 29: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/29.jpg)
Questions?
![Page 30: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/30.jpg)
*
๏ WSO2 ESB http://wso2.com/products/enterprise-service-bus
๏ WSO2 ESB Documentationhttps://docs.wso2.
org/display/ESB481/WSO2+Enterprise+Service+Bus+Documentation
๏ RESTful Integration with WSO2 ESBhttp://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/
๏ How to GET a Cup of Coffee the WSO2 Wayhttp://wso2.com/library/articles/2012/09/get-cup-coffee-wso2-way/
6
Links
![Page 31: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/31.jpg)
**
Business Model
![Page 32: Restful Integration with WSO2 ESB](https://reader034.vdocuments.mx/reader034/viewer/2022050920/54b6d86d4a7959ca538b4637/html5/thumbnails/32.jpg)
Contact us !