Question: Java REST Caculator In this lab youll be implementing a number of smaller functions as part of a REST based service. You will only need

Java REST Caculator In this lab youll be implementing a number of smaller functions as part of a REST based service. You will only need to create the server side of this service so no need for any browser client code. However, be sure to test your methods using either Postman or a client browser. For this lab used the context root /LabRest Create an online REST based calculator service with the path /calculator

Create methods for the basic arithmetic functions /Addition, /Subtraction, /Multiplication, /Division.

These will all be post operations since you will need to supply data.

Each of these calculator functions should accept two operands which will be passed via XML (ie your REST services will consume XML).

You will need to be able to return both XML and JSON responses.

Support returning the value of pi to the nth digit.

This will be a GET operation.

Use the form /pi/[digits] where [digits] is a pathparam.

Return in both xml or json.

Create an Addition method that takes any number of operands and adds them together.

For this you will read in the operands as query parameters. (ie ?a=1&b=1&c=3 etc).

Since these are query params you can use GET.

You can use UriInfo to get the query params.

@GET public Response get(@Context UriInfo uriInfo){ MultivaluedMap queryParams = uriInfo.getQueryParameters(); String nameParam = queryParams.getFirst("a");

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!