Introduction to Restful web service – A JAX-RS specification

In this article, we will learn and understand about web service and its different types. Further, we will concentrate on the Restful web service

Web Service

An inter-operable service hosted & up-running over the web which could be accessed by different independent clients like web browser

Types of Web Services

  • REST (Representational State Transfer)
  • SOAP (Simple Object Access Protocol)



  • JAX-RS 2.0 specification supports implementation of Restful web services
  • Different vendor implementation for this type are
    1. Apache CXF
    2. JBoss RestEasy
    3. Oracle Jersey (Prior 2.x)
    4. Glassfish Jersey (2.x)



  • JAX-WS 2.0 specification supports implementation of SOAP based web services
  • Different vendor implementation for this type are
    1. JAX-WS viz., Top-down and Bottom-up approach
    2. Apache Axis
    3. Apache Axis2
    4. Glassfish Metro JAX-WS
    5. Apache CXF
    6. Oracle WebLogic JAX-WS
    7. IBM WebSphere JAX-WS
    8. JBoss WS


Source: team


In this particular article, we will discuss and learn JAX-RS 2.0 specification based Restful web service. Later in the upcoming articles, we will use Apache’s CXF – Celtix + XFire to implement demo examples

Restful Web Services

In the REST of World, you call everything as resource and it is uniquely identified using URI i.e.; Uniform Resource Identifier. REST server and clients interacts using stateless HTTP protocol via four broadly classified HTTP verbs viz.,

  • POST            – to CREATE/insert resource
  • GET              – to READ/select/retrieve internal resource
  • PUT              – to UPDATE/modify the resource
  • DELETE         – to DELETE/remove internal resource representation

Note: That forms CRUD

Relationships between SQL and HTTP Verbs

 Action  SQL  HTTP verbs
Create Insert POST
Read Select GET
Update Update PUT
Delete Delete DELETE

Formats supported in Restful Web Services

  • XML
  • JSON
  • TEXT
  • Image
  • HTML
  • PDF
  • etc

Advantages of Rest web service

  • REST architectural pattern is basically lightweight in nature. So, when you have bandwidth constraints then prefer REST web service
  • Easy and fast to develop
  • Top sites like Twitter, Yahoo uses this pattern
  • Most social networking sites like uses REST web services
  • Mobile App development growing rapidly and for their server interaction, it uses this REST pattern as it is faster in processing request/response data

JAX-RS Annotations

These are the most commonly used JAX-RS Annotations, when developing REST based web service. In the upcoming articles, we will understand & use these annotations and implement demo examples

  • @Path (
  • @GET (
  • @POST (
  • @PUT (
  • @DELETE (
  • @PathParam (
  • @QueryParam (
  • @MatrixParam (
  • @FormParam (
  • @HeaderParam (
  • @Context (
  • @Consumes (
  • @Produces (

@Path annotation (explanation)

  • @Path specifies the relative URI path
  • It can be defined at class-level or method-level
  • Let understand by an example

1. Base URL for any web application is


2. Append <url-pattern> tag from web.xml with Base URL that forms


3. Append class-level @Path(“class-level”) annotation and then method-level @Path(“method-level”) annotation that forms


Go through the examples in the upcoming articles to understand other annotations in details


Read about SoapUI tutorials from



Apache CXF:
JBoss RestEasy:


Happy Coding !!
Happy Learning !!

Apache CXF: JAX-RS Restful web service using @PathParam annotation