Question: Question 1: (14 marks) You are asked to develop a RESTful web service application using JAVA programming language. We provided you with the JAVA class
Question 1: (14 marks)
You are asked to develop a RESTful web service application using JAVA programming language. We provided you with the JAVA class JasonAccess.java, this class includes methods to store and retrieve Jason objects from a persistent storage file. You are required to read the source code carefully and to get familiar with all implemented methods.
The following Jason value pairs needs to be stored on the server sides in a file (you can do so by calling the method JasonAccess.persist(Jason Object, file name) contains the following Jason value pairs:
jsonObjBuilder.add("Sami",1250);
jsonObjBuilder.add("Rami", 12500);
jsonObjBuilder.add("Samar",12600);
Within the main method you need to execute the following codes in order to store the Jason object:
public static void main(String[] args)
{
//Make a JSON ojbect representing a phone contact list
JsonObject myObj = JasonAccess.createCarObject();
System.out.println("Made a json object " + myObj);
JasonAccess.tellMeAbout(myObj);
//Write to a file
String fname = "JSON.txt";
JasonAccess.persist(myObj, fname);
myObj.close();
}
After exploring the class JasonAccess.java, you need to create a RESTful web service that offers two services as follows:
Implement the following RESTful methods:
The getStudentId () expect as argument a student name and once executed it returns the corresponding ID of that student, this can be done by querying the Jason object sorted on the server side. You need to complete this method by implementing the necessary statements.
@GET
@Path("/getStudentId/{name}")
@Produces(MediaType.TEXT_HTML)
public String getStudentId (@PathParam("name") String name) {
and the method getAlIStudents() expect no argument and once executed it returns the all students names and their Ids, this can be done returning the Jason object sorted on the server side. You need to complete this method by implementing the necessary statements.
@GET
@Path("/getAllStudents/")
@Produces(MediaType.TEXT_HTML)
public String getAllStudents () {
You are asked to provide an HTML page that can be used to execute both web service methods [2 marks].
You need also to provide a JAVA desktop (RESTful client application) application that can call both web service methods [2 marks].
All of this can be accomplished within one NetBeans web service project.
You are asked to provide the whole source and HTML page code of all the JAVA classes in one-word file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
