Over a million developers have joined DZone.

Introduction to RESTful Web Services—A JAX-RS Specification

DZone's Guide to

Introduction to RESTful Web Services—A JAX-RS Specification

Learn about web services, what they are, what they're used for, different types of web services, and their advantages over other specifications.

· Integration Zone ·
Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

In this article, we will learn about the different types of web services. Further, we will concentrate on RESTful web services.

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:

    • Apache CXF

    • JBoss RestEasy

    • Oracle Jersey (Prior 2.x)

    • 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 Axis2

Image title

Source: BenchResources.net 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



HTTP verbs













Formats Supported in RESTful Web Services

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

Advantages of RESTful Web Services

  • 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 Facebook.com 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 (javax.ws.rs.Path)
  • @GET (javax.ws.rs.GET)
  • @POST (javax.ws.rs.POST)
  • @PUT (javax.ws.rs.PUT)
  • @DELETE (javax.ws.rs.DELETE)
  • @PathParam (javax.ws.rs.PathParam)
  • @QueryParam (javax.ws.rs.QueryParam)
  • @MatrixParam (javax.ws.rs.MatrixParam)
  • @FormParam (javax.ws.rs.FormParam)
  • @HeaderParam (javax.ws.rs.HeaderParam)
  • @Context (javax.ws.rs.core.Context)
  • @Consumes (javax.ws.rs.Consumes)
  • @Produces (javax.ws.rs.Produces)

@Path annotation

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

Base URL for any web application is:


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


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 detail


Download A Buyer's Guide to Application and Data Integration, your one-stop-shop for research, checklists, and explanations for an application and data integration solution.

web services ,rest ,integration

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}