...
The next section outlines the way I ahve have exposed the services using the jersey api.
Code Block | ||||
---|---|---|---|---|
| ||||
@Path("/user") public class UserRestServices { private String genPassword() @GET @Path("/sayhello") @Produces(MediaType.TEXT_HTML) public String sayHtmlHelloTest() // Test entry point, call this from url in browser to make sure service up and running @GET @Path("/cu/{user}") @Produces(MediaType.APPLICATION_JSON) public Response createUser(@PathParam("user") String userId) // create a user from url in browser, calls __createUser @POST @Path("/cufo") @Consumes(MediaType.APPLICATION_JSON) public Response createUserFromObject(User usr) // create a user from java marshalled object, calls __createUser private Response __createUser( User usr ) // actually makes call to DB @POST @Path("/du") @Consumes(MediaType.APPLICATION_JSON) public Response deleteUser(User us) // deletes a user if they exist in DB @POST @Path("/uu/{user}") @Consumes(MediaType.APPLICATION_JSON) public Response updateUser(User us) // updates a user if they exist in DB @GET @Path("/fu/{user}/{pwd}") @Produces(MediaType.APPLICATION_JSON) public Response findUser(@PathParam("user") String userId, @PathParam("pwd") String pwd) // finds a user if they exist in the DB } |
The URIs I have exposed are
<base uri>/user/cu
<base uri>/user/cu/{userid}
<base uri>/user/fu
<base uri>/user/fu/{userid}/{pwd}
<base uri>/user/uu
<base uri>/user/uu/{userid}
<base uri>/user/du/
<base uri>/user/du/{userid}