SlideShare a Scribd company logo
RESTful Web services using Java
About Web service


• What is Web service?

• What is WSDL?

• What is SOAP?
WSDL Structure
<definitions>
   <types>
    definition of types........
   </types>
   <message>
    definition of a message....
   </message>
   <portType>
    definition of a port.......
   </portType>
   <binding>
    definition of a binding....
   </binding>
   </definitions>
SOAP Sample
POST /StockQuote HTTP/1.1
SOAPAction: "Some-URI“

<soapenv:Envelope xmlns:soapenv="......">
 <soapenv:Header/>
 <soapenv:Body>
   <it:GetEmployeeName>
     <it:ID>4118830901957010</it:ID>
   </it:GetEmployeeName>
 </soapenv:Body>
</soapenv:Envelope>
Have you ever wondered why
here is so much overhead in
designing a simple web service
like ‘GetEmployeeName’ using
SOAP?
REpresentational State Transfer
                (REST)

• REpresentational State Transfer

• What is JAX-RS?

• What is Jersey?
REST Concepts
• Resources (nouns)
  – Identified by a URI, For example:
    http://www.parts-depot.com/parts

• Uniform interface (verbs)
   – Small fixed set:
   Create, Read, Update, Delete

• State Representations
– data and state transferred between client and server
   XML, JSON, Atom, XHTML, ...
JAX-RS Introduction
• Set of Java APIs for development of
  web services built according to the REST
  principals
• Annotations
• Jersey is the open source , production quality,
  JAX-RS (JSR 311) Reference Implementation
  for building RESTful Web services.
• Jersey Homepage
  https://jersey.dev.java.net/
Use Standard Methods
Sample RESTful Web service
@Path("/helloworld/{name}")
public class HelloworldResource {
  @Context
  private UriInfo context;

    /** Creates a new instance of HelloworldResource */
    public HelloworldResource() {
    }

    /**
     * Retrieves representation of an instance of jaxrstest.HelloworldResource
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("text/plain")
    public String sayHello(@PathParam("name") String name,
                           @DefaultValue("HR") @QueryParam("dep") String department) {
       return "Hi "+name+" Welcome to "+ department +" department";
    }

    @GET
    @Path("/sunresource")
    public String testSubResource(){
      return "This is from Sub Resource";
    }

    /**
     * PUT method for updating or creating an instance of HelloworldResource
     * @param content representation for the resource
     * @return an HTTP response with content of the updated or created resource.
     */
    @PUT
    @Consumes("text/plain")
    public void putText(String content) {
       System.out.println("======"+content+"=====");
    }

}
Demo
HTTP Example
Examples on the web
• Google AJAX Search API
  – http://code.google.com/apis/ajaxsearch/
• Amazon S3
  – http://aws.amazon.com/s3
• Services exposing Atom Publishing Protocol or GData
  – i.e. Google apps like Google Calendar
• Accidentally RESTful
  – Flickr, Del.icio.us API
REST Framework alternatives
• Restlet (opensource client and server API)
  – http://www.restlet.org/
• CXF
  – HttpBinding
  – JAX-WS Provider/Dispatch API
• Axis2
  – HttpBinding (WSDL 2.0)
• JAX-RS
For More Information
• BOF-5613 - Jersey: RESTful Web Services Made Easy
• Official JSR Page
  > http://jcp.org/en/jsr/detail?id=311
• JSR Project
  > http://jsr311.dev.java.net/
• Reference Implementation
  > http://jersey.dev.java.net/
• Marc's Blog
  > http://weblogs.java.net/blog/mhadley/
• Paul's Blog
  > http://blogs.sun.com/sandoz/
• Jakub's Blog
  > http://blogs.sun.com/japod/

More Related Content

What's hot (20)

PPTX
Overview of RESTful web services
nbuddharaju
 
PDF
So various polymorphism in Scala
b0ris_1
 
PPTX
RESTEasy
Khushbu Joshi
 
PPTX
REST & RESTful Web Service
Hoan Vu Tran
 
KEY
Designing a RESTful web service
Filip Blondeel
 
PDF
Spring Web Services: SOAP vs. REST
Sam Brannen
 
PPTX
RESTful Web Services
Martin Necasky
 
PPTX
Restful webservice
Dong Ngoc
 
PPT
Introduction to JAX-RS
Andreas Bjärlestam
 
ODP
RESTing with JAX-RS
Ezewuzie Emmanuel Okafor
 
PPTX
Rest presentation
srividhyau
 
PPTX
WebLogic Developer Webcast 1: JPA 2.0
Jeffrey West
 
PPTX
Restful webservices
Kong King
 
PPT
Easy rest service using PHP reflection api
Matthieu Aubry
 
PDF
RESTful web
Alvin Qi
 
PDF
Json to hive_schema_generator
Payal Jain
 
PDF
Rest web services
Paulo Gandra de Sousa
 
PPTX
L18 REST API Design
Ólafur Andri Ragnarsson
 
PDF
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
PPTX
Rest and Rails
Chamnap Chhorn
 
Overview of RESTful web services
nbuddharaju
 
So various polymorphism in Scala
b0ris_1
 
RESTEasy
Khushbu Joshi
 
REST & RESTful Web Service
Hoan Vu Tran
 
Designing a RESTful web service
Filip Blondeel
 
Spring Web Services: SOAP vs. REST
Sam Brannen
 
RESTful Web Services
Martin Necasky
 
Restful webservice
Dong Ngoc
 
Introduction to JAX-RS
Andreas Bjärlestam
 
RESTing with JAX-RS
Ezewuzie Emmanuel Okafor
 
Rest presentation
srividhyau
 
WebLogic Developer Webcast 1: JPA 2.0
Jeffrey West
 
Restful webservices
Kong King
 
Easy rest service using PHP reflection api
Matthieu Aubry
 
RESTful web
Alvin Qi
 
Json to hive_schema_generator
Payal Jain
 
Rest web services
Paulo Gandra de Sousa
 
L18 REST API Design
Ólafur Andri Ragnarsson
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India
 
Rest and Rails
Chamnap Chhorn
 

Viewers also liked (6)

PPTX
Survey of restful web services frameworks
Vijay Prasad Gupta
 
PDF
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
IMC Institute
 
PDF
RESTful Web services using JAX-RS
Arun Gupta
 
PPTX
JUnit 5 - from Lambda to Alpha and beyond
Sam Brannen
 
PDF
IoT and WoT (Internet of Things and Web of Things)
Jonathan Jeon
 
PPTX
Consuming Restful APIs using Swagger v2.0
Pece Nikolovski
 
Survey of restful web services frameworks
Vijay Prasad Gupta
 
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
IMC Institute
 
RESTful Web services using JAX-RS
Arun Gupta
 
JUnit 5 - from Lambda to Alpha and beyond
Sam Brannen
 
IoT and WoT (Internet of Things and Web of Things)
Jonathan Jeon
 
Consuming Restful APIs using Swagger v2.0
Pece Nikolovski
 
Ad

Similar to Developing RESTful WebServices using Jersey (20)

PPTX
Building Restful Web Services with Java
Vassil Popovski
 
PPTX
Ppt on web development and this has all details
gogijoshiajmer
 
PDF
Rest web service
Hamid Ghorbani
 
PDF
JAX-RS Creating RESTFul services
Ludovic Champenois
 
PDF
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
PPTX
JAX-RS 2.0 and OData
Anil Allewar
 
PDF
RESTful Java With JAX RS 1st Edition Bill Burke
rohismhmob88
 
PPTX
Rest overview briefing
◄ vaquar khan ► ★✔
 
PDF
Lab swe-2013intro jax-rs
Aravindharamanan S
 
PDF
Introduction to Restful Web Services
weili_at_slideshare
 
PDF
RESTful Java With JAX RS 1st Edition Bill Burke
jolokmertah
 
PPTX
Java Web services
Sujit Kumar
 
PDF
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
PDF
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
PPT
ROA.ppt
KGSCSEPSGCT
 
PPTX
Rest with Java EE 6 , Security , Backbone.js
Carol McDonald
 
PPTX
Rest
Carol McDonald
 
PPTX
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
PDF
JAX-RS 2.0: RESTful Web Services
Arun Gupta
 
PDF
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
Building Restful Web Services with Java
Vassil Popovski
 
Ppt on web development and this has all details
gogijoshiajmer
 
Rest web service
Hamid Ghorbani
 
JAX-RS Creating RESTFul services
Ludovic Champenois
 
JAX-RS JavaOne Hyderabad, India 2011
Shreedhar Ganapathy
 
JAX-RS 2.0 and OData
Anil Allewar
 
RESTful Java With JAX RS 1st Edition Bill Burke
rohismhmob88
 
Rest overview briefing
◄ vaquar khan ► ★✔
 
Lab swe-2013intro jax-rs
Aravindharamanan S
 
Introduction to Restful Web Services
weili_at_slideshare
 
RESTful Java With JAX RS 1st Edition Bill Burke
jolokmertah
 
Java Web services
Sujit Kumar
 
Spark IT 2011 - Developing RESTful Web services with JAX-RS
Arun Gupta
 
Rest with java (jax rs) and jersey and swagger
Kumaraswamy M
 
ROA.ppt
KGSCSEPSGCT
 
Rest with Java EE 6 , Security , Backbone.js
Carol McDonald
 
JAX-RS. Developing RESTful APIs with Java
Jerry Kurian
 
JAX-RS 2.0: RESTful Web Services
Arun Gupta
 
JavaEE and RESTful development - WSO2 Colombo Meetup
Sagara Gunathunga
 
Ad

Developing RESTful WebServices using Jersey

  • 1. RESTful Web services using Java
  • 2. About Web service • What is Web service? • What is WSDL? • What is SOAP?
  • 3. WSDL Structure <definitions> <types> definition of types........ </types> <message> definition of a message.... </message> <portType> definition of a port....... </portType> <binding> definition of a binding.... </binding> </definitions>
  • 4. SOAP Sample POST /StockQuote HTTP/1.1 SOAPAction: "Some-URI“ <soapenv:Envelope xmlns:soapenv="......"> <soapenv:Header/> <soapenv:Body> <it:GetEmployeeName> <it:ID>4118830901957010</it:ID> </it:GetEmployeeName> </soapenv:Body> </soapenv:Envelope>
  • 5. Have you ever wondered why here is so much overhead in designing a simple web service like ‘GetEmployeeName’ using SOAP?
  • 6. REpresentational State Transfer (REST) • REpresentational State Transfer • What is JAX-RS? • What is Jersey?
  • 7. REST Concepts • Resources (nouns) – Identified by a URI, For example: http://www.parts-depot.com/parts • Uniform interface (verbs) – Small fixed set: Create, Read, Update, Delete • State Representations – data and state transferred between client and server XML, JSON, Atom, XHTML, ...
  • 8. JAX-RS Introduction • Set of Java APIs for development of web services built according to the REST principals • Annotations • Jersey is the open source , production quality, JAX-RS (JSR 311) Reference Implementation for building RESTful Web services. • Jersey Homepage https://jersey.dev.java.net/
  • 10. Sample RESTful Web service @Path("/helloworld/{name}") public class HelloworldResource { @Context private UriInfo context; /** Creates a new instance of HelloworldResource */ public HelloworldResource() { } /** * Retrieves representation of an instance of jaxrstest.HelloworldResource * @return an instance of java.lang.String */ @GET @Produces("text/plain") public String sayHello(@PathParam("name") String name, @DefaultValue("HR") @QueryParam("dep") String department) { return "Hi "+name+" Welcome to "+ department +" department"; } @GET @Path("/sunresource") public String testSubResource(){ return "This is from Sub Resource"; } /** * PUT method for updating or creating an instance of HelloworldResource * @param content representation for the resource * @return an HTTP response with content of the updated or created resource. */ @PUT @Consumes("text/plain") public void putText(String content) { System.out.println("======"+content+"====="); } }
  • 11. Demo
  • 13. Examples on the web • Google AJAX Search API – http://code.google.com/apis/ajaxsearch/ • Amazon S3 – http://aws.amazon.com/s3 • Services exposing Atom Publishing Protocol or GData – i.e. Google apps like Google Calendar • Accidentally RESTful – Flickr, Del.icio.us API
  • 14. REST Framework alternatives • Restlet (opensource client and server API) – http://www.restlet.org/ • CXF – HttpBinding – JAX-WS Provider/Dispatch API • Axis2 – HttpBinding (WSDL 2.0) • JAX-RS
  • 15. For More Information • BOF-5613 - Jersey: RESTful Web Services Made Easy • Official JSR Page > http://jcp.org/en/jsr/detail?id=311 • JSR Project > http://jsr311.dev.java.net/ • Reference Implementation > http://jersey.dev.java.net/ • Marc's Blog > http://weblogs.java.net/blog/mhadley/ • Paul's Blog > http://blogs.sun.com/sandoz/ • Jakub's Blog > http://blogs.sun.com/japod/