I am creating restful web service and i wanted to know how do we create a service with input parameters and also how to invoke it from a web browser.
For example
You can try this... put parameters as :
http://localhost:8080/WebApplication11/webresources/generic/getText?arg1=hello
in your browser...
package newpackage;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PUT;
import javax.ws.rs.QueryParam;
@Path("generic")
public class GenericResource {
@Context
private UriInfo context;
/**
* Creates a new instance of GenericResource
*/
public GenericResource() {
}
/**
* Retrieves representation of an instance of newpackage.GenericResource
* @return an instance of java.lang.String
*/
@GET
@Produces("text/plain")
@Consumes("text/plain")
@Path("getText/")
public String getText(@QueryParam("arg1")
@DefaultValue("") String arg1) {
return arg1 ; }
@PUT
@Consumes("text/plain")
public void putText(String content) {
}
}