SlideShare une entreprise Scribd logo
1  sur  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>

Contenu connexe

Tendances

Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
b_kathir
 
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
Carol McDonald
 
Csajsp Chapter5
Csajsp Chapter5Csajsp Chapter5
Csajsp Chapter5
Adil Jafri
 

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

En vedette

En vedette (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
 

Similaire à RestFull Webservices with JAX-RS

JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011JAX-RS JavaOne Hyderabad, India 2011
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
Andrew Curioso
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
Li Yi
 
03 form-data
03 form-data03 form-data
03 form-data
snopteck
 
jQuery : Talk to server with Ajax
jQuery : Talk to server with AjaxjQuery : Talk to server with Ajax
jQuery : Talk to server with Ajax
Wildan Maulana
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
Leigh Dodds
 
Creating APIs over RDF
Creating APIs over RDFCreating APIs over RDF
Creating APIs over RDF
Leigh Dodds
 
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
reswin
 

Similaire à 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
 

Plus 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
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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