Upload
wso2
View
903
Download
3
Tags:
Embed Size (px)
DESCRIPTION
Citation preview
Chanaka FernandoTechnical Lead
Ishan JayawardenaSenior Software Engineer
May 29 2014
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.
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
What WSO2 delivers
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
*
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
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)
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.
Trend towards REST
๏ Amazon AWS (Over 90% of the clients use RESTful API)
๏ Google Maps
๏ Yahoo
๏ Ebay
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
ESB REST APIs
๏ Exposes RESTful APIs
๏ REST → SOAP conversion
๏ SOAP → REST conversion
๏ REST → REST conversion
ESB REST APIs
๏ Creating a REST API...
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)
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)
ESB REST APIs : Resources
ESB REST APIs : Resources
/people
ESB REST APIs : Resources
/people
GET/staff/*
ESB REST APIs : Resources
/people
GET/staff/*
POST/add?name={name}&id={id}
ESB REST APIs : Resources
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
๏ 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
Use Case : Pizza Shop
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
<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
<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
<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
<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
Complete samplehttp://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/
Use Case : Pizza Shop
Questions?
*
๏ 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
**
Business Model
Contact us !