SlideShare a Scribd company logo
July 29, 2017
Kumaraswamy Gowda
Software Architect, PSL
Build RESTful
application
with JAX-RS
Agenda
2
• What is REST
• REST principles
• Java API for RESTful Web Services (JAX-RS, defined in
JSR 311)
• HTTP Methods
• Annotations
• Client APIs
• SWAGGER – Expose and Test REST API
HTTP Example
3
Request
GET /music/artists/beatles/recordings HTTP/1.1
Host: media.example.com
Accept: application/xml
Response
HTTP/1.1 200 OK
Date: Sat, 08 Jul 2017 16:41:58 GMT
Content-Type: application/xml(or json); charset=UTF-8
<?xml version="1.0"?>
<recordings xmlns="…">
<recording>…</recording>
…
</recordings>
Method Resource
Representation
State
transfer
{
"recordings": {
"recording": [
{},
{}
]
}
}
What is REST
4
• REpresentational State Transfer is an architectural style
for building online applications
• First described by Roy Fielding in his doctoral dissertation
in 2000
• Lightweight, Scalable and maintainable
• Stateless by nature
• Client server protocol, almost always HTTP
• Clients can be any programming language
REST architecture for Web
5
Resources
Web Container
Resources
Web Container
REST Principles
6
• Everything is a resource
• Assign everything an ID
• Uniform Interface- fixed set of four
create, read, update, delete operations
o PUT, GET, POST, and DELETE
• Representation of the Resource
o JSON, XML, TEXT
/reports
--------------------
GET – list all reports
PUT – not supported
POST – create a report
DELETE – not supported
/reports/{id}
--------------------
GET – get report details
PUT – update report
POST – not supported
DELETE – delete a report
{
"recordings": {
"recording": [
{},
{}
]
}
}
<?xml version="1.0"?>
<recordings xmlns="…">
<recording>…</recording>
…
</recordings>
REST Principles contd…
7
• Stateless
• Link
o /reports to contain links to all reports like /reports/1,
/reports/2
• Pagination
o Limit data per request
o Enables clients to navigate forward or backward
• Caching
• Fields, sorting, filtering, versioning
JAX-RS (2.0)
8
• Java API for RESTful Web Services (JAX-RS, defined in
JSR 311)
• Designed to make it easy to develop applications that use
the REST architecture
• Implementations
o Jersey
o Apache CXF
o Apache Wink
o Restlet
• JAX-RS uses annotations available from Java SE 5
Annotations
9
• @Path
o Sets path to base URL +
@Path value
o https://server:port/eclipseapp
/api/reports
o @Path(“/reports”/{id})
o @Path("/username/{usernam
e : [a-zA-Z][a-zA-Z_0-9]}")
o @Path("{id : d+}")
@GET, @POST, @PUT, @DELETE
10
/reports – GET POST
/reports/{reportid} – GET, DELETE, PUT
/reports/{reportid}/templates
/reports/{reportid}/templates/{templateid}
@Produces and @Consumes
11
• MIME type content returned
• Equivalent to Content-type response header
@PathParam @QueryParam @HeaderParam
@FormDataParam @FormParam
12
• Binds values from request to the parameter
Deployment Descriptor (web.xml)
13
<servlet>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.abc.xyz.services</param-value>
</init-param>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.abc.xyz.service.MyApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
Client APIs
14
• Remember URLConnection? Or apache http client
libraries?
• Fluent API available from JAX-RS 2.0
Client
Builder
Client
Web
Target
Request
Building
Response..
SWAGGER
API developer tools for the OpenAPI Specification
15
What is Swagger and Why Swagger?
16
• Simple representation of your RESTFul API
• Declarative resource specification
• JSON specification
• Developers and documentation… hahaha
• Why Jersey Client / JUNIT or Rest Client (Poster /
Postman) or API document for your client or boss?
• Swagger UI to interact with the API in a sandbox UI
• Support your existing RESTFul API without change
Swagger Specification
17
Web Services
• Resource Listing
• API Description
Create Swagger Specification
• Manually - writing the JSON by hand
• Codgen - converts annotations in your code into swagger
specification
Swagger Specifications
18
19
Swagger Tools
20
Adjacent tools also provided by the
Swagger project are
Tool Description
Swagger JS Javascript library for consuming Swagger-defined APIs from both client and node.js app
Swagger Node Swagger module for node.js
Swagger-Socket expose/invoke Swagger defined APIs over WebSockets
Swagger Parser Standalone library for parsing Swagger definitions from Java
Tools for nearly every language and
allows you to deploy server instances
to get your API up and running -
Clojure, Go, JS, Java, .Net, Node,
PHP, Python, Ruby, Scala
References
21
• http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html
• http://www.vogella.com/tutorials/REST/article.html
• https://jersey.java.net/documentation/latest/jaxrs-
resources.html
• https://github.com/koushikkothagal/messenger
• http://swagger.io/specification/
• https://github.com/swagger-api/swagger-spec
• https://github.com/swagger-api/swagger-core
• http://petstore.swagger.io/
22
Thanks!
Any questions?
You can find me at
➝https://www.linkedin.com/in/kumaraswamym/
➝kumaraswamy.m@gmail.com
RESTful application with JAX-RS and how to expose and test them

More Related Content

PDF
Java colombo-deep-dive-into-jax-rs
Sagara Gunathunga
 
PDF
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
PPTX
L18 REST API Design
Ólafur Andri Ragnarsson
 
PDF
Request-Response Cycle of Ruby on Rails App
Nathalie Steinmetz
 
PPTX
RESTful Web Service using Swagger
Hong-Jhih Lin
 
PPTX
RestFul Web Services In Drupal 8
Gajendra Sharma
 
PDF
Globus for System Administrators (GlobusWorld Tour - UCSD)
Globus
 
PPTX
HBaseConEast2016: HBase and Spark, State of the Art
Michael Stack
 
Java colombo-deep-dive-into-jax-rs
Sagara Gunathunga
 
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
L18 REST API Design
Ólafur Andri Ragnarsson
 
Request-Response Cycle of Ruby on Rails App
Nathalie Steinmetz
 
RESTful Web Service using Swagger
Hong-Jhih Lin
 
RestFul Web Services In Drupal 8
Gajendra Sharma
 
Globus for System Administrators (GlobusWorld Tour - UCSD)
Globus
 
HBaseConEast2016: HBase and Spark, State of the Art
Michael Stack
 

What's hot (20)

PDF
(ATS6-PLAT04) Query service
BIOVIA
 
PDF
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
BIOVIA
 
PPTX
Oak, the architecture of Apache Jackrabbit 3
Jukka Zitting
 
PPT
File System On Steroids
Jukka Zitting
 
PPTX
Apache Falcon DevOps
Sanjeev Tripurari
 
PDF
Globus Command Line Interface (APS Workshop)
Globus
 
PDF
Globus Endpoint Setup and Configuration - XSEDE14 Tutorial
Globus
 
PPTX
Apache Phoenix Query Server PhoenixCon2016
Josh Elser
 
PDF
Native REST Web Services with Oracle 11g
Marcelo Ochoa
 
PDF
(ATS6-PLAT07) Managing AEP in an enterprise environment
BIOVIA
 
PPTX
Apache phoenix
Osama Hussein
 
PPTX
The architecture of oak
Michael Dürig
 
PDF
Tutorial: Managing Protected Data with Globus Connect Server v5
Globus
 
PPTX
HiveWarehouseConnector
Eric Wohlstadter
 
PDF
(ATS6-PLAT02) Accelrys Catalog and Protocol Validation
BIOVIA
 
PPTX
Apache Flink - A Stream Processing Engine
Aljoscha Krettek
 
PDF
LDAP Development Using Spring LDAP
LDAPCon
 
PDF
(ATS6-PLAT03) What's behind Discngine collections
BIOVIA
 
PDF
Avik_RailsTutorial
tutorialsruby
 
PPTX
Archive integration with RDF
Lars Marius Garshol
 
(ATS6-PLAT04) Query service
BIOVIA
 
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
BIOVIA
 
Oak, the architecture of Apache Jackrabbit 3
Jukka Zitting
 
File System On Steroids
Jukka Zitting
 
Apache Falcon DevOps
Sanjeev Tripurari
 
Globus Command Line Interface (APS Workshop)
Globus
 
Globus Endpoint Setup and Configuration - XSEDE14 Tutorial
Globus
 
Apache Phoenix Query Server PhoenixCon2016
Josh Elser
 
Native REST Web Services with Oracle 11g
Marcelo Ochoa
 
(ATS6-PLAT07) Managing AEP in an enterprise environment
BIOVIA
 
Apache phoenix
Osama Hussein
 
The architecture of oak
Michael Dürig
 
Tutorial: Managing Protected Data with Globus Connect Server v5
Globus
 
HiveWarehouseConnector
Eric Wohlstadter
 
(ATS6-PLAT02) Accelrys Catalog and Protocol Validation
BIOVIA
 
Apache Flink - A Stream Processing Engine
Aljoscha Krettek
 
LDAP Development Using Spring LDAP
LDAPCon
 
(ATS6-PLAT03) What's behind Discngine collections
BIOVIA
 
Avik_RailsTutorial
tutorialsruby
 
Archive integration with RDF
Lars Marius Garshol
 
Ad

Similar to RESTful application with JAX-RS and how to expose and test them (20)

PPTX
Building Restful Web Services with Java
Vassil Popovski
 
PPTX
Ppt on web development and this has all details
gogijoshiajmer
 
ODP
RESTing with JAX-RS
Ezewuzie Emmanuel Okafor
 
PDF
JAX-RS Creating RESTFul services
Ludovic Champenois
 
PDF
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
PPTX
JAX-RS 2.0 and OData
Anil Allewar
 
PDF
RESTful Web services using JAX-RS
Arun Gupta
 
PDF
RESTful Java With JAX RS 1st Edition Bill Burke
rohismhmob88
 
PPT
Developing RESTful WebServices using Jersey
b_kathir
 
PPTX
#6 (RESTtful Web Wervices)
Ghadeer AlHasan
 
PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
PDF
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
PDF
RESTful Java With JAX RS 1st Edition Bill Burke
jolokmertah
 
PDF
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
PDF
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
Arun Gupta
 
PDF
Lab swe-2013intro jax-rs
Aravindharamanan S
 
PDF
Rest services with Jax-rs
Guddu Spy
 
PDF
Making Java REST with JAX-RS 2.0
Dmytro Chyzhykov
 
PPTX
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
PPTX
6 Months Industrial Training in Spring Framework
Arcadian Learning
 
Building Restful Web Services with Java
Vassil Popovski
 
Ppt on web development and this has all details
gogijoshiajmer
 
RESTing with JAX-RS
Ezewuzie Emmanuel Okafor
 
JAX-RS Creating RESTFul services
Ludovic Champenois
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
JAX-RS 2.0 and OData
Anil Allewar
 
RESTful Web services using JAX-RS
Arun Gupta
 
RESTful Java With JAX RS 1st Edition Bill Burke
rohismhmob88
 
Developing RESTful WebServices using Jersey
b_kathir
 
#6 (RESTtful Web Wervices)
Ghadeer AlHasan
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
RESTful Java With JAX RS 1st Edition Bill Burke
jolokmertah
 
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
S313265 - Advanced Java API for RESTful Web Services at JavaOne Brazil 2010
Arun Gupta
 
Lab swe-2013intro jax-rs
Aravindharamanan S
 
Rest services with Jax-rs
Guddu Spy
 
Making Java REST with JAX-RS 2.0
Dmytro Chyzhykov
 
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
6 Months Industrial Training in Spring Framework
Arcadian Learning
 
Ad

Recently uploaded (20)

PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PPTX
Audio Editing and it's techniques in computer graphics.pptx
fosterbayirinia3
 
PPTX
AZ900_SLA_Pricing_2025_LondonIT (1).pptx
chumairabdullahph
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
PDF
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
PPTX
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPT
FALLSEM2025-26_ISWE304L_TH_VL2025260102786_2025-07-10_Reference-Material-II.ppt
AKSHAYA255427
 
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
PDF
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
devilbrown689
 
DOCX
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
PDF
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
PPTX
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
PPTX
Save Business Costs with CRM Software for Insurance Agents
Insurance Tech Services
 
PPTX
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
PDF
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
PPTX
Presentation of Computer CLASS 2 .pptx
darshilchaudhary558
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
Audio Editing and it's techniques in computer graphics.pptx
fosterbayirinia3
 
AZ900_SLA_Pricing_2025_LondonIT (1).pptx
chumairabdullahph
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Winning Business in a Slowing Economy, How CPQ helps Manufacturers Protect Ma...
systemscincom
 
The Role of Automation and AI in EHS Management for Data Centers.pdf
TECH EHS Solution
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
What to consider before purchasing Microsoft 365 Business Premium_PDF.pdf
Q-Advise
 
Visualising Data with Scatterplots in IBM SPSS Statistics.pptx
Version 1 Analytics
 
FALLSEM2025-26_ISWE304L_TH_VL2025260102786_2025-07-10_Reference-Material-II.ppt
AKSHAYA255427
 
Materi_Pemrograman_Komputer-Looping.pptx
RanuFajar1
 
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
devilbrown689
 
The Five Best AI Cover Tools in 2025.docx
aivoicelabofficial
 
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
Save Business Costs with CRM Software for Insurance Agents
Insurance Tech Services
 
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
Presentation of Computer CLASS 2 .pptx
darshilchaudhary558
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 

RESTful application with JAX-RS and how to expose and test them

  • 1. July 29, 2017 Kumaraswamy Gowda Software Architect, PSL Build RESTful application with JAX-RS
  • 2. Agenda 2 • What is REST • REST principles • Java API for RESTful Web Services (JAX-RS, defined in JSR 311) • HTTP Methods • Annotations • Client APIs • SWAGGER – Expose and Test REST API
  • 3. HTTP Example 3 Request GET /music/artists/beatles/recordings HTTP/1.1 Host: media.example.com Accept: application/xml Response HTTP/1.1 200 OK Date: Sat, 08 Jul 2017 16:41:58 GMT Content-Type: application/xml(or json); charset=UTF-8 <?xml version="1.0"?> <recordings xmlns="…"> <recording>…</recording> … </recordings> Method Resource Representation State transfer { "recordings": { "recording": [ {}, {} ] } }
  • 4. What is REST 4 • REpresentational State Transfer is an architectural style for building online applications • First described by Roy Fielding in his doctoral dissertation in 2000 • Lightweight, Scalable and maintainable • Stateless by nature • Client server protocol, almost always HTTP • Clients can be any programming language
  • 5. REST architecture for Web 5 Resources Web Container Resources Web Container
  • 6. REST Principles 6 • Everything is a resource • Assign everything an ID • Uniform Interface- fixed set of four create, read, update, delete operations o PUT, GET, POST, and DELETE • Representation of the Resource o JSON, XML, TEXT /reports -------------------- GET – list all reports PUT – not supported POST – create a report DELETE – not supported /reports/{id} -------------------- GET – get report details PUT – update report POST – not supported DELETE – delete a report { "recordings": { "recording": [ {}, {} ] } } <?xml version="1.0"?> <recordings xmlns="…"> <recording>…</recording> … </recordings>
  • 7. REST Principles contd… 7 • Stateless • Link o /reports to contain links to all reports like /reports/1, /reports/2 • Pagination o Limit data per request o Enables clients to navigate forward or backward • Caching • Fields, sorting, filtering, versioning
  • 8. JAX-RS (2.0) 8 • Java API for RESTful Web Services (JAX-RS, defined in JSR 311) • Designed to make it easy to develop applications that use the REST architecture • Implementations o Jersey o Apache CXF o Apache Wink o Restlet • JAX-RS uses annotations available from Java SE 5
  • 9. Annotations 9 • @Path o Sets path to base URL + @Path value o https://server:port/eclipseapp /api/reports o @Path(“/reports”/{id}) o @Path("/username/{usernam e : [a-zA-Z][a-zA-Z_0-9]}") o @Path("{id : d+}")
  • 10. @GET, @POST, @PUT, @DELETE 10 /reports – GET POST /reports/{reportid} – GET, DELETE, PUT /reports/{reportid}/templates /reports/{reportid}/templates/{templateid}
  • 11. @Produces and @Consumes 11 • MIME type content returned • Equivalent to Content-type response header
  • 12. @PathParam @QueryParam @HeaderParam @FormDataParam @FormParam 12 • Binds values from request to the parameter
  • 13. Deployment Descriptor (web.xml) 13 <servlet> <servlet-name>JAX-RS Servlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.abc.xyz.services</param-value> </init-param> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.abc.xyz.service.MyApplication</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>JAX-RS Servlet</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping>
  • 14. Client APIs 14 • Remember URLConnection? Or apache http client libraries? • Fluent API available from JAX-RS 2.0 Client Builder Client Web Target Request Building Response..
  • 15. SWAGGER API developer tools for the OpenAPI Specification 15
  • 16. What is Swagger and Why Swagger? 16 • Simple representation of your RESTFul API • Declarative resource specification • JSON specification • Developers and documentation… hahaha • Why Jersey Client / JUNIT or Rest Client (Poster / Postman) or API document for your client or boss? • Swagger UI to interact with the API in a sandbox UI • Support your existing RESTFul API without change
  • 17. Swagger Specification 17 Web Services • Resource Listing • API Description Create Swagger Specification • Manually - writing the JSON by hand • Codgen - converts annotations in your code into swagger specification
  • 19. 19
  • 20. Swagger Tools 20 Adjacent tools also provided by the Swagger project are Tool Description Swagger JS Javascript library for consuming Swagger-defined APIs from both client and node.js app Swagger Node Swagger module for node.js Swagger-Socket expose/invoke Swagger defined APIs over WebSockets Swagger Parser Standalone library for parsing Swagger definitions from Java Tools for nearly every language and allows you to deploy server instances to get your API up and running - Clojure, Go, JS, Java, .Net, Node, PHP, Python, Ruby, Scala
  • 21. References 21 • http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html • http://www.vogella.com/tutorials/REST/article.html • https://jersey.java.net/documentation/latest/jaxrs- resources.html • https://github.com/koushikkothagal/messenger • http://swagger.io/specification/ • https://github.com/swagger-api/swagger-spec • https://github.com/swagger-api/swagger-core • http://petstore.swagger.io/
  • 22. 22 Thanks! Any questions? You can find me at ➝https://www.linkedin.com/in/kumaraswamym/ ➝[email protected]

Editor's Notes

  • #2: Today let us try to learn building RESTful application using JAX-RS
  • #3: We’ll understand what is REST and what are it’s principles And then know about JAX-RS Understand different HTTP methods that helps building REST services Understand annotation from JAX-RS that simplifies building REST services Look at client APIs from JAR-RS 2.0 And final on how to expose REST APIs
  • #4: Let’s look at a basic HTTP request and response Looking at the URI, the client is requesting to GET all the recordings from beatles band The URI is /music/…./recordings HTTP method is GET The clients ways, I’m expecting an XML as a response All of these forms a request Let’s take a looks at the response The HTTP request status code is 200, which means successful The content-type header says that response data is in xml format.. Or json format
  • #5: Web services are services that are exposed to the internet for programmatic access... an online API that you can call from your code it's a concept, it’s an idea, there is no specification, and no committee to tell you what is right or what is wrong it's an architectural style, set of guide lines for architecting your services… build the services as per your need following the REST principles It was first described by Roy Fielding… he is also one the principal authors of the HTTP specifications Lightweight, without unnecessary headers as in SOAP services Concepts of REST are mainly influenced by HTTP
  • #6: I'm sure many of you would have heard of Facebook and Twitter app... you must have seen games that would post on the Facebook wall, even though those games are not designed by Facebook themselves How do they do this? by calling online APIs
  • #7: Think of resources and build unique URLs for it Resources/URIs should be nouns and not verbs... the URIs should be documents, messages, reports.... and not getMessages, deleteMessages.. it should typically be nouns and not the action it's not message... it should be messages getMessages.do?id=10 deleteMessages.do?id=25 putMessages.do HTTP methods: They have specific meaning to each of these methods You are using these methods with or without your knowledge... like while post a comment or while opening a page in the web browser In the REST world, you don't make call to getReports.. you make a get request to the reports resource URI you don't call a deleteOrder, you make a delete request to the order resource URI the URI tells what entity or resource is being operated upon and the method tells what that operation is.
  • #8: Caching - Cache response on the service layer... for a short time - Stateless - Every request should be independent request - every request should send the state -
  • #9: It provide a way to map the meta-information to your methods through annotation. It’s a POJO based resource classes Injects
  • #10: Which resource you want to act upon In JAX-RS, you can use @Path to bind URI pattern to a Java method. The base URL + @Path parameter before the full URL URL matching with @Path pattern URI matching with parameter: The value within an open brace “{” and close brace “}”, is represents a parameter, and can be access with @PathParam URI matching with regular expression:
  • #11: @Path mentions that resource you want to act upon… @GET, @POST tells what action would that be… To do that, you could add annotations like… to the java method
  • #12: The @Produces annotation is used to specify the MIME media types or representations a resource can produce and send back to the client Can be applied to class level or method level The @Consumes annotation is used to specify which MIME media types of representations a resource can accept, or consume, from the client. Can be applied to class level or method level
  • #14: In the dep desc, define servlet container handling all ur jax-rs service requests….
  • #15: Specification - human and machine readable specification -
  • #16: How many of you have used HTTP URLConnection API from java? Was the experience pleasant?
  • #17: Let me ask you all a question. How many of you develop web services? How do you test the web services that you're developing? write junits (junits are still important to test the services for regressions) java.net.URLConnection API, use libraries like HTTP Client, Jersey Client Rest Client from the broswers like Poster, POSTMAN create a simple/sample UI app to test the APIs For someone to consume your services, you have to expose the API. How do you share/expose your APIs to others? Like what are the services are available, what parameters to be passed, is it a GET or POST document the web services in a word document when an API is updated, new service is added, a service is deprecated, you need to update the document...
  • #18: What is Swagger Swagger is a simple yet powerful representation of your RESTful API. It is an open source tool and has support for nearly every language like Closure, JS, Go, Scala, .Net, PHP, Python, Ruby and not to forget, JAVA. Swagger provides a declarative resource specification, allowing users to understand and consume services without knowledge of server implementation, enabling both developers and non-developers to interact with the API, providing clear insight into how the API responds to parameters and options. Why Swagger - Developer and documentation... no offense to anyone... developers usually hate documentation... we tend to avoid documentation whenever we could - Swagger provides a sandbox UI to interact with the API... wow... how is it different form POSTER or POSTMAN... let's see
  • #19: Specification - human and machine readable specification -