SlideShare uma empresa Scribd logo
1 de 31
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>

Mais conteúdo relacionado

Mais procurados

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 servicesnbuddharaju
 
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 LondonArun Gupta
 
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 BasicIMC Institute
 
Json to hive_schema_generator
Json to hive_schema_generatorJson to hive_schema_generator
Json to hive_schema_generatorPayal Jain
 
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 2013Jagadish Prasath
 
JSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLJSP Standart Tag Lİbrary - JSTL
JSP Standart Tag Lİbrary - JSTLseleciii44
 
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
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleEmiliano Pecis
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESYoga Raja
 

Mais procurados (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
 

Destaque

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.0Dmytro 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 ServicesDaniel 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 RestyGWTDavid 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 JerseyStormpath
 
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-RSFahad Golra
 

Destaque (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
 

Semelhante a 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-RSArun Gupta
 
Ellerslie User Group - ReST Presentation
Ellerslie User Group - ReST PresentationEllerslie User Group - ReST Presentation
Ellerslie User Group - ReST PresentationAlex Henderson
 
Spring MVC 3 Restful
Spring MVC 3 RestfulSpring MVC 3 Restful
Spring MVC 3 Restfulknight1128
 
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 QueryOlaf Hartig
 
RESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRESTful SCA with Apache Tuscany
RESTful SCA with Apache TuscanyRaymond 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 ToolsMatt 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 appsHenk Jurriens
 

Semelhante a 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
 

Mais de 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 HTML5Neil 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 STEPNeil 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
 

Mais de 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
 

Último

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

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