SlideShare a Scribd company logo
1 of 18
What is REST ?
• REpresentational State Transfer
• Its an architectural style
• Its Peculiar features are
1. Client-server
2. Stateless
3. Cached
4. Uniform interface
5. Layered system
P.S.R Patnaik (CyberJungle.Org)
Components of REST Style
Architecture
• Resources are identified by uniform resource
identifiers (URIs)
• Resources are manipulated through their
representations
• Messages are self-descriptive and stateless
• Multiple representations are accepted or sent
P.S.R Patnaik (CyberJungle.Org)
Representation in REST
• Resources are first-class objects
– Indeed, “object” is a subtype of “resource”
• Resources are retrieved not as character
strings or BLOBs but as complete
representations
P.S.R Patnaik (CyberJungle.Org)
State
• “State” in REST means application/session
state
• State is associated with the content
transferred from client to server back to client
• Thus any server/application can continue
transaction from the point where it was left
off
P.S.R Patnaik (CyberJungle.Org)
REST
• State in REST is transferred by exchanging
messages between Server and Client
• REST messages are usually a XML or JSON
string containing information pertaining to
state of application.
• REST uses HTTP for STATE transfer and HTTP is
the most RESTful protocol with GET , PUT ,
POST , DELETE operations !!
P.S.R Patnaik (CyberJungle.Org)
RESTful Web Services
• Now we know what is REST and its
components , so what is RESTful webservice ?
P.S.R Patnaik (CyberJungle.Org)
RESTful Webservice
• A RESTful Web service follows four basic
design principles:
• Uses HTTP methods
• Be stateless as far as possible.
• Expose directory/folder structure-like URI/URL
• Transfer XML, JavaScript Object Notation
(JSON), or both.
P.S.R Patnaik (CyberJungle.Org)
HTTP Methods and REST
• GET: Reading access of the resource
(idempotent).
• PUT : Creates a new resource. (idempotent)
• DELETE: Removes the resources. (idempotent)
• POST: Updates an existing resource or creates
a new resource. (idempotent)
P.S.R Patnaik (CyberJungle.Org)
RESTful Webservice Using JAVA
• JSR 311: JAX-RS: The JavaTM API for RESTful
Web Services
• JSR 311 : API for providing support for
RESTful(Representational State Transfer) Web
Services in the Java Platform.
P.S.R Patnaik (CyberJungle.Org)
How to develop RESTful Webservice in
Java
• By using simple Java Servlet and conforming
to REST standards and best practices
• By using JSR 311 implementation like famous
Jersey framework , Jackson (fasterxml),
Resteasy, Apache CXF.
P.S.R Patnaik (CyberJungle.Org)
RESTful Webservice Best Practices
• Provide a distinct URI for each resource you
wish to expose.
• Use nouns in your URIs, they highlight the fact
that resources are things and not actions.
• Methods that map to GET should not change
any data.
• Methods that map to POST should change the
data.
• Make your service stateless.
P.S.R Patnaik (CyberJungle.Org)
Designing RESTful Webservice
• Define the resources the service will expose. A
service exposes one or more resources that are
organized as a tree.
• Define what actions you want to be able to
perform on each resource.
• Map the actions to the appropriate HTTP verbs.
• For example you want to create service to book
ticket. For example, booking ticket
/bookingticket/getavailability
/bookingticket/bookticket
/bookingticket/updateavailability
P.S.R Patnaik (CyberJungle.Org)
Simple RESTful Java Webservice
using Jersey and Eclipse Kepler
Prerequisites
• Eclipse Kepler
• Jersey API (https://jersey.java.net/)
• Apache Tomcat v7
P.S.R Patnaik (CyberJungle.Org)
Simple RESTful Java Webservice
using Jersey and Eclipse Kepler
• Create a Dynamic Web Project
• Configure it to use Apache Tomcat v7 as
Runtime. (ensure that tomcat runs on JDK 7)
• Add Jersey libraries to Project’s Build Path and
also lib directory of Web project
• Add a package with name “cyberjungle” to the
web project’s src directory.
• Add a java file and name it as
HelloSimpleRestfulWS.java
P.S.R Patnaik (CyberJungle.Org)
Simple RESTful Java Web service
using Jersey and Eclipse Kepler
• Add following code to the file
HelloSimpleRestfulWS.java
package cyberjungle;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@Path("/hello")
public class HelloSimpleRestfulWS {
@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {
String output = "Hello !! How are you " + msg.toUpperCase();
return Response.status(200).entity(output).build();
}
}
P.S.R Patnaik (CyberJungle.Org)
Simple RESTful Java Web service
using Jersey and Eclipse Kepler
• Addweb.xml to the projects WEB-INF
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Simple Restful Web Application Using Jersey</display-name>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>cyberjungle</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/restfulws/*</url-pattern>
</servlet-mapping>
</web-app>
P.S.R Patnaik (CyberJungle.Org)
Simple RESTful Java Web service
using Jersey and Eclipse Kepler
• Run the application
• Browse the following URL
http://localhost:8080/SimpleRESTfulJavaWebS
ervice/restfulws/hello/psrpatnaik
• The output would look like.
Hello !! How are you PSRPATNAIK
P.S.R Patnaik (CyberJungle.Org)
Reference Resources
• IBM Developers Work.
• Oracle RESTfulWeb Services Developer's Guide
• Jersey User Guide.
P.S.R Patnaik (CyberJungle.Org)

More Related Content

What's hot

Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionseyelliando dias
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSCarol McDonald
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RSArun Gupta
 
Designing a RESTful web service
Designing a RESTful web serviceDesigning a RESTful web service
Designing a RESTful web serviceFilip Blondeel
 
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEREST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEreneechemel
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptxHarry Potter
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webserviceDong Ngoc
 
RESTful web
RESTful webRESTful web
RESTful webAlvin Qi
 
WebLogic Developer Webcast 1: JPA 2.0
WebLogic Developer Webcast 1: JPA 2.0WebLogic Developer Webcast 1: JPA 2.0
WebLogic Developer Webcast 1: JPA 2.0Jeffrey West
 

What's hot (20)

Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey IntroductionseyCwinters Intro To Rest And JerREST and Jersey Introductionsey
Cwinters Intro To Rest And JerREST and Jersey Introductionsey
 
RESTful Web Services with JAX-RS
RESTful Web Services with JAX-RSRESTful Web Services with JAX-RS
RESTful Web Services with JAX-RS
 
RESTful Web services using JAX-RS
RESTful Web services using JAX-RSRESTful Web services using JAX-RS
RESTful Web services using JAX-RS
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Designing a RESTful web service
Designing a RESTful web serviceDesigning a RESTful web service
Designing a RESTful web service
 
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLEREST Easy with AngularJS - ng-grid CRUD EXAMPLE
REST Easy with AngularJS - ng-grid CRUD EXAMPLE
 
REST API Design
REST API DesignREST API Design
REST API Design
 
L18 REST API Design
L18 REST API DesignL18 REST API Design
L18 REST API Design
 
How to build a rest api.pptx
How to build a rest api.pptxHow to build a rest api.pptx
How to build a rest api.pptx
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
Rest web services
Rest web servicesRest web services
Rest web services
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
RESTful web
RESTful webRESTful web
RESTful web
 
Web Services
Web ServicesWeb Services
Web Services
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
WebLogic Developer Webcast 1: JPA 2.0
WebLogic Developer Webcast 1: JPA 2.0WebLogic Developer Webcast 1: JPA 2.0
WebLogic Developer Webcast 1: JPA 2.0
 

Viewers also liked

Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service designRamin Orujov
 
Cd Group - iPad App - The Real Deal - SCUG
Cd Group - iPad App - The Real Deal - SCUGCd Group - iPad App - The Real Deal - SCUG
Cd Group - iPad App - The Real Deal - SCUGbarizon
 
Panduan microsoft exel 2007
Panduan microsoft exel 2007Panduan microsoft exel 2007
Panduan microsoft exel 2007Adre Ridwan
 
Resilient Enterprise Messaging with WSO2 ESB
Resilient Enterprise Messaging with WSO2 ESBResilient Enterprise Messaging with WSO2 ESB
Resilient Enterprise Messaging with WSO2 ESBWSO2
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful FundamentalsSuresh Madhra
 
Restul web development
Restul web developmentRestul web development
Restul web developmentSetfire Media
 
Implementing Web Services In Java
Implementing Web Services In JavaImplementing Web Services In Java
Implementing Web Services In JavaEdureka!
 
Soap vs. rest - which is right web service protocol for your need?
Soap vs. rest -  which is right web service protocol for your need?Soap vs. rest -  which is right web service protocol for your need?
Soap vs. rest - which is right web service protocol for your need?Vijay Prasad Gupta
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesArun Gupta
 
OAuth with Restful Web Services
OAuth with Restful Web Services OAuth with Restful Web Services
OAuth with Restful Web Services Vinay H G
 
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web ServicesIntroduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web Servicesecosio GmbH
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightOliver Gierke
 
Spring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepSpring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepGuo Albert
 

Viewers also liked (20)

Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service design
 
Cd Group - iPad App - The Real Deal - SCUG
Cd Group - iPad App - The Real Deal - SCUGCd Group - iPad App - The Real Deal - SCUG
Cd Group - iPad App - The Real Deal - SCUG
 
Panduan microsoft exel 2007
Panduan microsoft exel 2007Panduan microsoft exel 2007
Panduan microsoft exel 2007
 
Resilient Enterprise Messaging with WSO2 ESB
Resilient Enterprise Messaging with WSO2 ESBResilient Enterprise Messaging with WSO2 ESB
Resilient Enterprise Messaging with WSO2 ESB
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Restul web development
Restul web developmentRestul web development
Restul web development
 
Overview of web services
Overview of web servicesOverview of web services
Overview of web services
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Implementing Web Services In Java
Implementing Web Services In JavaImplementing Web Services In Java
Implementing Web Services In Java
 
Soap vs. rest - which is right web service protocol for your need?
Soap vs. rest -  which is right web service protocol for your need?Soap vs. rest -  which is right web service protocol for your need?
Soap vs. rest - which is right web service protocol for your need?
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
OAuth with Restful Web Services
OAuth with Restful Web Services OAuth with Restful Web Services
OAuth with Restful Web Services
 
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web ServicesIntroduction to SOAP/WSDL Web Services and RESTful Web Services
Introduction to SOAP/WSDL Web Services and RESTful Web Services
 
Web services
Web servicesWeb services
Web services
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
 
Spring + JPA + DAO Step by Step
Spring + JPA + DAO Step by StepSpring + JPA + DAO Step by Step
Spring + JPA + DAO Step by Step
 

Similar to Introduction to RESTful Webservices in JAVA

Java Web services
Java Web servicesJava Web services
Java Web servicesSujit Kumar
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using SwaggerHong-Jhih Lin
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Josh Juneau
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with DropwizardAndrei Savu
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesLudovic Champenois
 
Utilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesUtilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesJosh Juneau
 
Developing and Hosting REST APIs 3.7
Developing and Hosting REST APIs 3.7Developing and Hosting REST APIs 3.7
Developing and Hosting REST APIs 3.7StephenKardian
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup Sagara Gunathunga
 
REST APIs for the Internet of Things
REST APIs for the Internet of ThingsREST APIs for the Internet of Things
REST APIs for the Internet of ThingsMichael Koster
 
REST APIs for an Internet of Things
REST APIs for an Internet of ThingsREST APIs for an Internet of Things
REST APIs for an Internet of ThingsMichael Koster
 
How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages Marc Leinbach
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restishGrig Gheorghiu
 
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionJasonRafeMiller
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7Lukáš Fryč
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Servicesweili_at_slideshare
 

Similar to Introduction to RESTful Webservices in JAVA (20)

Java Web services
Java Web servicesJava Web services
Java Web services
 
RESTful Web Service using Swagger
RESTful Web Service using SwaggerRESTful Web Service using Swagger
RESTful Web Service using Swagger
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
Migrating to Jakarta EE 10
Migrating to Jakarta EE 10Migrating to Jakarta EE 10
Migrating to Jakarta EE 10
 
Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)JAVA EE DEVELOPMENT (JSP and Servlets)
JAVA EE DEVELOPMENT (JSP and Servlets)
 
JAX-RS Creating RESTFul services
JAX-RS Creating RESTFul servicesJAX-RS Creating RESTFul services
JAX-RS Creating RESTFul services
 
Utilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with MicroservicesUtilizing JSF Front Ends with Microservices
Utilizing JSF Front Ends with Microservices
 
Developing and Hosting REST APIs 3.7
Developing and Hosting REST APIs 3.7Developing and Hosting REST APIs 3.7
Developing and Hosting REST APIs 3.7
 
JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup JavaEE and RESTful development - WSO2 Colombo Meetup
JavaEE and RESTful development - WSO2 Colombo Meetup
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
REST APIs for the Internet of Things
REST APIs for the Internet of ThingsREST APIs for the Internet of Things
REST APIs for the Internet of Things
 
REST APIs for an Internet of Things
REST APIs for an Internet of ThingsREST APIs for an Internet of Things
REST APIs for an Internet of Things
 
How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages How to call REST API without knowing any programming languages
How to call REST API without knowing any programming languages
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
 
Web Technologies in Java EE 7
Web Technologies in Java EE 7Web Technologies in Java EE 7
Web Technologies in Java EE 7
 
Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
Databasecentricapisonthecloudusingplsqlandnodejscon3153oow2016 160922021655
 
Introduction to Restful Web Services
Introduction to Restful Web ServicesIntroduction to Restful Web Services
Introduction to Restful Web Services
 

Recently uploaded

Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 

Recently uploaded (20)

Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 

Introduction to RESTful Webservices in JAVA

  • 1. What is REST ? • REpresentational State Transfer • Its an architectural style • Its Peculiar features are 1. Client-server 2. Stateless 3. Cached 4. Uniform interface 5. Layered system P.S.R Patnaik (CyberJungle.Org)
  • 2. Components of REST Style Architecture • Resources are identified by uniform resource identifiers (URIs) • Resources are manipulated through their representations • Messages are self-descriptive and stateless • Multiple representations are accepted or sent P.S.R Patnaik (CyberJungle.Org)
  • 3. Representation in REST • Resources are first-class objects – Indeed, “object” is a subtype of “resource” • Resources are retrieved not as character strings or BLOBs but as complete representations P.S.R Patnaik (CyberJungle.Org)
  • 4. State • “State” in REST means application/session state • State is associated with the content transferred from client to server back to client • Thus any server/application can continue transaction from the point where it was left off P.S.R Patnaik (CyberJungle.Org)
  • 5. REST • State in REST is transferred by exchanging messages between Server and Client • REST messages are usually a XML or JSON string containing information pertaining to state of application. • REST uses HTTP for STATE transfer and HTTP is the most RESTful protocol with GET , PUT , POST , DELETE operations !! P.S.R Patnaik (CyberJungle.Org)
  • 6. RESTful Web Services • Now we know what is REST and its components , so what is RESTful webservice ? P.S.R Patnaik (CyberJungle.Org)
  • 7. RESTful Webservice • A RESTful Web service follows four basic design principles: • Uses HTTP methods • Be stateless as far as possible. • Expose directory/folder structure-like URI/URL • Transfer XML, JavaScript Object Notation (JSON), or both. P.S.R Patnaik (CyberJungle.Org)
  • 8. HTTP Methods and REST • GET: Reading access of the resource (idempotent). • PUT : Creates a new resource. (idempotent) • DELETE: Removes the resources. (idempotent) • POST: Updates an existing resource or creates a new resource. (idempotent) P.S.R Patnaik (CyberJungle.Org)
  • 9. RESTful Webservice Using JAVA • JSR 311: JAX-RS: The JavaTM API for RESTful Web Services • JSR 311 : API for providing support for RESTful(Representational State Transfer) Web Services in the Java Platform. P.S.R Patnaik (CyberJungle.Org)
  • 10. How to develop RESTful Webservice in Java • By using simple Java Servlet and conforming to REST standards and best practices • By using JSR 311 implementation like famous Jersey framework , Jackson (fasterxml), Resteasy, Apache CXF. P.S.R Patnaik (CyberJungle.Org)
  • 11. RESTful Webservice Best Practices • Provide a distinct URI for each resource you wish to expose. • Use nouns in your URIs, they highlight the fact that resources are things and not actions. • Methods that map to GET should not change any data. • Methods that map to POST should change the data. • Make your service stateless. P.S.R Patnaik (CyberJungle.Org)
  • 12. Designing RESTful Webservice • Define the resources the service will expose. A service exposes one or more resources that are organized as a tree. • Define what actions you want to be able to perform on each resource. • Map the actions to the appropriate HTTP verbs. • For example you want to create service to book ticket. For example, booking ticket /bookingticket/getavailability /bookingticket/bookticket /bookingticket/updateavailability P.S.R Patnaik (CyberJungle.Org)
  • 13. Simple RESTful Java Webservice using Jersey and Eclipse Kepler Prerequisites • Eclipse Kepler • Jersey API (https://jersey.java.net/) • Apache Tomcat v7 P.S.R Patnaik (CyberJungle.Org)
  • 14. Simple RESTful Java Webservice using Jersey and Eclipse Kepler • Create a Dynamic Web Project • Configure it to use Apache Tomcat v7 as Runtime. (ensure that tomcat runs on JDK 7) • Add Jersey libraries to Project’s Build Path and also lib directory of Web project • Add a package with name “cyberjungle” to the web project’s src directory. • Add a java file and name it as HelloSimpleRestfulWS.java P.S.R Patnaik (CyberJungle.Org)
  • 15. Simple RESTful Java Web service using Jersey and Eclipse Kepler • Add following code to the file HelloSimpleRestfulWS.java package cyberjungle; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; @Path("/hello") public class HelloSimpleRestfulWS { @GET @Path("/{param}") public Response getMsg(@PathParam("param") String msg) { String output = "Hello !! How are you " + msg.toUpperCase(); return Response.status(200).entity(output).build(); } } P.S.R Patnaik (CyberJungle.Org)
  • 16. Simple RESTful Java Web service using Jersey and Eclipse Kepler • Addweb.xml to the projects WEB-INF <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Simple Restful Web Application Using Jersey</display-name> <servlet> <servlet-name>jersey-serlvet</servlet-name> <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>cyberjungle</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jersey-serlvet</servlet-name> <url-pattern>/restfulws/*</url-pattern> </servlet-mapping> </web-app> P.S.R Patnaik (CyberJungle.Org)
  • 17. Simple RESTful Java Web service using Jersey and Eclipse Kepler • Run the application • Browse the following URL http://localhost:8080/SimpleRESTfulJavaWebS ervice/restfulws/hello/psrpatnaik • The output would look like. Hello !! How are you PSRPATNAIK P.S.R Patnaik (CyberJungle.Org)
  • 18. Reference Resources • IBM Developers Work. • Oracle RESTfulWeb Services Developer's Guide • Jersey User Guide. P.S.R Patnaik (CyberJungle.Org)