Friday, August 16, 2013

RESTful WEB SERVICES and RESTFul JAVA with RESTEasy


A simple RESTEasy Helloworld example
Technologies used
  1. Maven
  2. JBOSS AS
  3. RESTEasy
First let us take a look at the pom.xml

  4.0.0
  in.itsvenkis.blogspot
  resteasy-examples
  0.0.1-SNAPSHOT
  war
  jboss-resteasy
  Rest easy tutorials
  
  resteasyTutorials
  
  
   
      jboss
      http://repository.jboss.org/maven2
   
  
      
          org.jboss.resteasy
          resteasy-jaxrs
          3.0.0.Final

web.xml
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    
        resteasy.resources
        itsvenkis.blogspot.in.resteasy.examples.HelloWorldService
    
    
        resteasy.servlet.mapping.prefix
        /resteasy
    
    
        
            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
    
    
        resteasy
        
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
    
    
        resteasy
        /resteasy/*
    
Service class
package itsvenkis.blogspot.in.resteasy.examples;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/helloworld")
public class HelloWorldService {

    @GET
    @Path("/{param}")
    public Response greetUser(@PathParam("param") String name) {
        return Response.status(200).entity("Hello World " + name).build();
    }
}
 
Now build and deploy the war file and start your server and try this url http://localhost:8080/resteasyTutorials/resteasy/helloworld/nandu
I will post more tutorials on RESTEasy, Hornet Q, JBOSS,CDI..... in the future
Dear Readers, kindly like us on facebook to see whats happening on this blog

No comments:

Post a Comment