SlideShare a Scribd company logo
Sabyasachi Ghosh, Senior Application Engneer Oracle India, @neilghosh Developing RESTful Web services with JAX-RS
Java API for RESTful Web Services (JAX-RS) Standard annotation-driven API that aims to help developers build RESTful Web services in Java
RESTful Application Cycle Resources are identified by URIs ↓ Clients communicate with resources via requests using a standard set of methods ↓ Requests and responses contain resource representations in formats identified by media types ↓ Responses contain URIs that link to further resources
[object Object]
Standard set of methods
Link things together
Multiple representations
Stateless communications
[object Object]
Resources are identified by URIs ,[object Object]
No required interfaces ,[object Object],[object Object]
Embedded parameters for non-fixed parts of the URI
Annotate class or “sub-resource locator” method
Resources are identified by URIs @Path("orders/{order_id}") public class OrderResource {   @GET  @Path("customer") CustomerResource getCustomer( @PathParam(“order_id”)int id ) {...} }
Standard Set of Methods Purpose Method Remove DELETE Update or create with a known ID PUT Update or create without a known ID POST Read, possibly cached GET
Standard Set of Methods ,[object Object]
@HttpMethod  meta-annotation allows extensions, e.g. WebDAV ,[object Object]
Flexible method signatures, annotations on parameters specify mapping from request
Return value mapped to response
Standard Set of Methods @Path("properties/ {name} ") public class SystemProperty { @GET Property get(@PathParam(" name ") String name) {...} @PUT Property set(@PathParam(" name ") String name, String value ) {...} }
Parameters Template parameters and Regular expressions @Path("customers/ {firstname}-{lastname} ") @Path(" { id : d+} ") Matrix Parameters example.cars.com/mercedes/e55;color=black/2006 Query Paremetsrs DELETE /orders/233?cancel=true
Multiple Representations ,[object Object]
JSON
(X)HTML ,[object Object]
Support content negotiation ,[object Object]
URI-based GET /foo.json
Content Negotiation: Accept Header Accept: application/xml Accept: application/json;q=1.0, text/xml;q=0.5, application/xml;q=0.5, @GET @Produces({"application/xml","application/json"}) Order getOrder(@PathParam(" order_id ") String id) { ... } @GET @Produces("text/plain") String getOrder2(@PathParam("order_id") String id) { ... }
Content Negotiation: URL-based @Path("/orders") public class OrderResource { @Path("{orderId}.xml")    @Produces(“application/xml”)   @GET    public Order getOrderInXML(@PathParam("orderId") String orderId) { . . .   } @Path("{orderId}.json")    @Produces(“application/json”)   @GET   public Order getOrderInJSON(@PathParam("orderId") String orderId) { . . .   } }
Content Negotiation import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.PathParam; @Path("/actor/{id}") @GET @Produces("application/json") @PathParam("id") import javax.inject.Inject; import javax.enterprise.context.RequestScoped; @RequestScoped public class ActorResource { @Inject DatbaseBean db; public Actor getActor(  int id) { return db.findActorById(id); } }
Link Things Together <order self=&quot; http://example.com/orders/101230 &quot;> <customer ref=&quot; http://example.com/customers/bar &quot;> <product ref=&quot; http://example.com/products/21034 &quot;/> <amount value=&quot;1&quot;/> </order>
Responses Contain Links HTTP/1.1 201 Created Date: Wed, 03 Jun 2009 16:41:58 GMT Server: Apache/1.3.6 Location:  http://example.com/properties/foo Content-Type: application/order+xml Content-Length: 184 <property self=&quot; http://example.com/properties/foo &quot;> <parent ref=&quot; http://example.com/properties/bar &quot;/> <name>Foo</name> <value>1</value> </order>

More Related Content

What's hot

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
nbuddharaju
 
Jersey and JAX-RS
Jersey and JAX-RSJersey and JAX-RS
Jersey and JAX-RS
Eduardo Pelegri-Llopart
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
Arun Gupta
 
Introduction to JAX-RS
Introduction to JAX-RSIntroduction to JAX-RS
Introduction to JAX-RS
Andreas Bjärlestam
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
IMC Institute
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generator
Payal Jain
 
OAuth: Trust Issues
OAuth: Trust IssuesOAuth: Trust Issues
OAuth: Trust Issues
Lorna Mitchell
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
Jagadish Prasath
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTL
seleciii44
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
Adarsh Patel
 
Csajsp Chapter5
Csajsp Chapter5Csajsp Chapter5
Csajsp Chapter5Adil Jafri
 
Servlet basics
Servlet basicsServlet basics
Servlet basics
Santosh Dhoundiyal
 
RESTEasy
RESTEasyRESTEasy
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
Emiliano Pecis
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
Yoga Raja
 

What's hot (18)

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Jersey and JAX-RS
Jersey and JAX-RSJersey and JAX-RS
Jersey and JAX-RS
 
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX LondonJAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
JAX-RS 2.0: New and Noteworthy in RESTful Web services API at JAX London
 
Introduction to JAX-RS
Introduction to JAX-RSIntroduction to JAX-RS
Introduction to JAX-RS
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generator
 
OAuth: Trust Issues
OAuth: Trust IssuesOAuth: Trust Issues
OAuth: Trust Issues
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013JAX RS 2.0 - OTN Bangalore 2013
JAX RS 2.0 - OTN Bangalore 2013
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTL
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
 
Csajsp Chapter5
Csajsp Chapter5Csajsp Chapter5
Csajsp Chapter5
 
Servlet basics
Servlet basicsServlet basics
Servlet basics
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 

Viewers also liked

Web Services JAX-RS RESTful y SOAP
Web Services JAX-RS RESTful y SOAPWeb Services JAX-RS RESTful y SOAP
Web Services JAX-RS RESTful y SOAP
ismaelmartincolmenarejo
 
Making Java REST with JAX-RS 2.0
Making Java REST with JAX-RS 2.0Making Java REST with JAX-RS 2.0
Making Java REST with JAX-RS 2.0
Dmytro Chyzhykov
 
JSR 339 - Java API for RESTful Web Services
JSR 339 - Java API for RESTful Web ServicesJSR 339 - Java API for RESTful Web Services
JSR 339 - Java API for RESTful Web Services
Daniel Cunha
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
David Chandler
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And Jersey
Stormpath
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
Fahad Golra
 

Viewers also liked (6)

Web Services JAX-RS RESTful y SOAP
Web Services JAX-RS RESTful y SOAPWeb Services JAX-RS RESTful y SOAP
Web Services JAX-RS RESTful y SOAP
 
Making Java REST with JAX-RS 2.0
Making Java REST with JAX-RS 2.0Making Java REST with JAX-RS 2.0
Making Java REST with JAX-RS 2.0
 
JSR 339 - Java API for RESTful Web Services
JSR 339 - Java API for RESTful Web ServicesJSR 339 - Java API for RESTful Web Services
JSR 339 - Java API for RESTful Web Services
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
REST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And JerseyREST API Design for JAX-RS And Jersey
REST API Design for JAX-RS And Jersey
 
Lecture 7 Web Services JAX-WS & JAX-RS
Lecture 7   Web Services JAX-WS & JAX-RSLecture 7   Web Services JAX-WS & JAX-RS
Lecture 7 Web Services JAX-WS & JAX-RS
 

Similar to RestFull Webservices with JAX-RS

Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
Ellerslie User Group - ReST Presentation
Ellerslie User Group - ReST PresentationEllerslie User Group - ReST Presentation
Ellerslie User Group - ReST Presentation
Alex Henderson
 
Spring MVC 3 Restful
Spring MVC 3 RestfulSpring MVC 3 Restful
Spring MVC 3 Restful
knight1128
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011Shreedhar Ganapathy
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API DevelopmentAndrew Curioso
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
An Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and QueryAn Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and Query
Olaf Hartig
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
Carol McDonald
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
Alfresco Software
 
RESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRESTful SCA with Apache Tuscany
RESTful SCA with Apache Tuscany
Raymond Feng
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxWildan Maulana
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDFLeigh Dodds
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDFLeigh Dodds
 
Dart Power Tools
Dart Power ToolsDart Power Tools
Dart Power Tools
Matt Norris
 
Design And Implementation Of Web Service Testing Framework Mit Template
Design And Implementation Of Web Service Testing Framework Mit TemplateDesign And Implementation Of Web Service Testing Framework Mit Template
Design And Implementation Of Web Service Testing Framework Mit Templatereswin
 
Building linked data apps
Building linked data appsBuilding linked data apps
Building linked data apps
Henk Jurriens
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
Anil Kumar Panigrahi
 

Similar to RestFull Webservices with JAX-RS (20)

Spark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RSSpark IT 2011 - Developing RESTful Web services with JAX-RS
Spark IT 2011 - Developing RESTful Web services with JAX-RS
 
Ellerslie User Group - ReST Presentation
Ellerslie User Group - ReST PresentationEllerslie User Group - ReST Presentation
Ellerslie User Group - ReST Presentation
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
Spring MVC 3 Restful
Spring MVC 3 RestfulSpring MVC 3 Restful
Spring MVC 3 Restful
 
JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Rest
RestRest
Rest
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
An Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and QueryAn Overview on PROV-AQ: Provenance Access and Query
An Overview on PROV-AQ: Provenance Access and Query
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
RESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRESTful SCA with Apache Tuscany
RESTful SCA with Apache Tuscany
 
03 form-data
03 form-data03 form-data
03 form-data
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
 
Dart Power Tools
Dart Power ToolsDart Power Tools
Dart Power Tools
 
Design And Implementation Of Web Service Testing Framework Mit Template
Design And Implementation Of Web Service Testing Framework Mit TemplateDesign And Implementation Of Web Service Testing Framework Mit Template
Design And Implementation Of Web Service Testing Framework Mit Template
 
Building linked data apps
Building linked data appsBuilding linked data apps
Building linked data apps
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 

More from Neil Ghosh

GOLD AG Report in IEEE Hyderabad AGM 2013
GOLD AG Report in IEEE Hyderabad AGM 2013GOLD AG Report in IEEE Hyderabad AGM 2013
GOLD AG Report in IEEE Hyderabad AGM 2013Neil Ghosh
 
Introduction to JavaFx and HTML5
Introduction to JavaFx and HTML5Introduction to JavaFx and HTML5
Introduction to JavaFx and HTML5
Neil Ghosh
 
GOLD at IEEE Hyderabad SAGM 2012
GOLD at IEEE Hyderabad SAGM 2012GOLD at IEEE Hyderabad SAGM 2012
GOLD at IEEE Hyderabad SAGM 2012Neil Ghosh
 
Astronomy at Pecha Kuch Night Hyderabad Volume 9
Astronomy at Pecha Kuch Night Hyderabad Volume 9 Astronomy at Pecha Kuch Night Hyderabad Volume 9
Astronomy at Pecha Kuch Night Hyderabad Volume 9 Neil Ghosh
 
IEEE GOLD STEP
IEEE GOLD  STEPIEEE GOLD  STEP
IEEE GOLD STEP
Neil Ghosh
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScriptNeil Ghosh
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web servicesNeil Ghosh
 
Creating REST Webservice With NetBeans
Creating REST Webservice With NetBeansCreating REST Webservice With NetBeans
Creating REST Webservice With NetBeansNeil Ghosh
 

More from Neil Ghosh (10)

GOLD AG Report in IEEE Hyderabad AGM 2013
GOLD AG Report in IEEE Hyderabad AGM 2013GOLD AG Report in IEEE Hyderabad AGM 2013
GOLD AG Report in IEEE Hyderabad AGM 2013
 
Introduction to JavaFx and HTML5
Introduction to JavaFx and HTML5Introduction to JavaFx and HTML5
Introduction to JavaFx and HTML5
 
GOLD at IEEE Hyderabad SAGM 2012
GOLD at IEEE Hyderabad SAGM 2012GOLD at IEEE Hyderabad SAGM 2012
GOLD at IEEE Hyderabad SAGM 2012
 
Astronomy at Pecha Kuch Night Hyderabad Volume 9
Astronomy at Pecha Kuch Night Hyderabad Volume 9 Astronomy at Pecha Kuch Night Hyderabad Volume 9
Astronomy at Pecha Kuch Night Hyderabad Volume 9
 
Astro quiz
Astro quizAstro quiz
Astro quiz
 
IEEE GOLD STEP
IEEE GOLD  STEPIEEE GOLD  STEP
IEEE GOLD STEP
 
Introduction to javaScript
Introduction to javaScriptIntroduction to javaScript
Introduction to javaScript
 
Intro to web services
Intro to web servicesIntro to web services
Intro to web services
 
Creating REST Webservice With NetBeans
Creating REST Webservice With NetBeansCreating REST Webservice With NetBeans
Creating REST Webservice With NetBeans
 
Edited
EditedEdited
Edited
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

RestFull Webservices with JAX-RS

  • 1. Sabyasachi Ghosh, Senior Application Engneer Oracle India, @neilghosh Developing RESTful Web services with JAX-RS
  • 2. Java API for RESTful Web Services (JAX-RS) Standard annotation-driven API that aims to help developers build RESTful Web services in Java
  • 3. RESTful Application Cycle Resources are identified by URIs ↓ Clients communicate with resources via requests using a standard set of methods ↓ Requests and responses contain resource representations in formats identified by media types ↓ Responses contain URIs that link to further resources
  • 4.
  • 5. Standard set of methods
  • 9.
  • 10.
  • 11.
  • 12. Embedded parameters for non-fixed parts of the URI
  • 13. Annotate class or “sub-resource locator” method
  • 14. Resources are identified by URIs @Path(&quot;orders/{order_id}&quot;) public class OrderResource { @GET @Path(&quot;customer&quot;) CustomerResource getCustomer( @PathParam(“order_id”)int id ) {...} }
  • 15. Standard Set of Methods Purpose Method Remove DELETE Update or create with a known ID PUT Update or create without a known ID POST Read, possibly cached GET
  • 16.
  • 17.
  • 18. Flexible method signatures, annotations on parameters specify mapping from request
  • 19. Return value mapped to response
  • 20. Standard Set of Methods @Path(&quot;properties/ {name} &quot;) public class SystemProperty { @GET Property get(@PathParam(&quot; name &quot;) String name) {...} @PUT Property set(@PathParam(&quot; name &quot;) String name, String value ) {...} }
  • 21. Parameters Template parameters and Regular expressions @Path(&quot;customers/ {firstname}-{lastname} &quot;) @Path(&quot; { id : d+} &quot;) Matrix Parameters example.cars.com/mercedes/e55;color=black/2006 Query Paremetsrs DELETE /orders/233?cancel=true
  • 22.
  • 23. JSON
  • 24.
  • 25.
  • 27. Content Negotiation: Accept Header Accept: application/xml Accept: application/json;q=1.0, text/xml;q=0.5, application/xml;q=0.5, @GET @Produces({&quot;application/xml&quot;,&quot;application/json&quot;}) Order getOrder(@PathParam(&quot; order_id &quot;) String id) { ... } @GET @Produces(&quot;text/plain&quot;) String getOrder2(@PathParam(&quot;order_id&quot;) String id) { ... }
  • 28. Content Negotiation: URL-based @Path(&quot;/orders&quot;) public class OrderResource { @Path(&quot;{orderId}.xml&quot;) @Produces(“application/xml”) @GET public Order getOrderInXML(@PathParam(&quot;orderId&quot;) String orderId) { . . . } @Path(&quot;{orderId}.json&quot;) @Produces(“application/json”) @GET public Order getOrderInJSON(@PathParam(&quot;orderId&quot;) String orderId) { . . . } }
  • 29. Content Negotiation import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.PathParam; @Path(&quot;/actor/{id}&quot;) @GET @Produces(&quot;application/json&quot;) @PathParam(&quot;id&quot;) import javax.inject.Inject; import javax.enterprise.context.RequestScoped; @RequestScoped public class ActorResource { @Inject DatbaseBean db; public Actor getActor( int id) { return db.findActorById(id); } }
  • 30. Link Things Together <order self=&quot; http://example.com/orders/101230 &quot;> <customer ref=&quot; http://example.com/customers/bar &quot;> <product ref=&quot; http://example.com/products/21034 &quot;/> <amount value=&quot;1&quot;/> </order>
  • 31. Responses Contain Links HTTP/1.1 201 Created Date: Wed, 03 Jun 2009 16:41:58 GMT Server: Apache/1.3.6 Location: http://example.com/properties/foo Content-Type: application/order+xml Content-Length: 184 <property self=&quot; http://example.com/properties/foo &quot;> <parent ref=&quot; http://example.com/properties/bar &quot;/> <name>Foo</name> <value>1</value> </order>
  • 32.
  • 33. UriBuilder provides facilities to easily construct URIs for resources
  • 34. Responses Contain Links @Context UriInfo i; SystemProperty p = ... UriBuilder b = i.getBaseUriBuilder(); URI u = b.path(SystemProperties.class) .path(p.getName()).build(); List<URI> ancestors = i.getMatchedURIs(); URI parent = ancestors.get(1);
  • 35. Responses Contain Links UriBuilder builder = UriBuilder.fromPath(&quot;/customers/{id}&quot;); builder.scheme(&quot;http&quot;) .host(&quot;{hostname}&quot;) .queryParam(&quot;param={param}&quot;); http://{hostname}/customers/{id}?param={param} UriBuilder clone = builder.clone(); URI uri = clone.build(&quot;example.com&quot;, &quot;333&quot;, &quot;value&quot;); http://example.com/customers/333?param=value
  • 36. Response codes and Exception Successful HTTP : 200 to 399 200 – OK 204 – No Content Standard HTTP error : 400 to 599 404 – Not Found 406 - Not Acceptable 405 - Method Not Allowed java.lang.Exception java.lang.RuntimeException javax.ws.rs.WebApplicationException throw new WebApplicationException(Response.Status.NOT_FOUND);
  • 37.
  • 39. Everything required to process a request contained in the request
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 49.
  • 50.
  • 51. JAX-RS 1.1 Jersey Client API – Code Sample Client client = Client.create(); WebResource resource = client.resource(“...”); //curl http://example.com/base String s = resource.get(String.class); //curl -HAccept:text/plain http://example.com/base String s = resource. accept(“text/plain”). get(String.class); http://blogs.oracle.com/enterprisetechtips/entry/consuming_restful_web_services_with
  • 52.
  • 53. Generated OOTB for the application <application xmlns=&quot;http://research.sun.com/wadl/2006/10&quot;> <doc xmlns:jersey=&quot;http://jersey.dev.java.net/&quot; jersey:generatedBy=&quot;Jersey: 1.1.4.1 11/24/2009 01:37 AM&quot;/> <resources base=&quot; http://localhost:8080/HelloWADL/resources/ &quot;> <resource path=&quot;generic&quot;> <method id=&quot;getText&quot; name=&quot; GET &quot;> <response> <representation mediaType=&quot;text/plain&quot;/> </response> </method> <method id=&quot;putText&quot; name=&quot; PUT &quot;> <request> <representation mediaType=&quot;text/plain&quot;/> </request> </method> </resource> </resources> </application>
  • 54.
  • 58. Demo
  • 59. Sabyasachi Ghosh, Senior Application Engneer Oracle India, @neilghosh Developing RESTful Web services with JAX-RS Thank You