• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help about Get Post Put Delete in Restful webservice  RSS feed

 
dylan payne
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need your help and advice. This is my first project in jersey. I don't know much about this topic. I'm still learning. I created my school project. But I have some problems on the web service side. Firstly I should explain my project. I have got 3 tables in my database. Movie,User,Ratings
Here my Movie table columns. I will ask you some points about Description column of the Movie table. I will use these methods to these columns.
Movie= Description (get,put,post and delete) I have to use all methods in this page.
movieTitle (get)
pictureURL (get,put)
generalRating (get,post)

I built my Description page. But I'm not sure if its working or not .(My database is not ready to check them). Here is my page. I wrote this page, looking at the example pages. Can you help me to find the problems and errors. I just want to do simple methods get(just reading data), post(update existing data), put(create new data), delete(delete specific data) these things.What should I do now, is my code okay or do you have alternative advice? I need your help guys


 
L Foster
Ranch Hand
Posts: 242
14
Android Angular Framework AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am reading it right (and I don't always, so if not I apologize in advance), you need some way to test that the right methods are getting invoked.

This looks like a job for Unit Testing. It may be a new concept, but the sooner you learn about it, the better. When "your database is not ready" (or even when you don't want to make a mess in your database, or that would take a long time) you can mock your DAO. You probably have only a skeletal DAO as it is. When you get advanced enough, you can set a mock DAO, or a real DAO by situation. There are frameworks for doing that sort of thing. But for now, you can just have your MovieDAO print little messages when you invoke those RESTful methods. Just print the name of the MovieDAO method that was called. You can print the messages using System.out.println, or with log4j/slf4j/etc. (if you have not heard of these yet, just use the println).

The other part of this, of course, is the front end. It sounds like you already know how to call this thing in web-like fashion. If you have any doubts, you'll want to be certain whether POST or GET, or whatever, is being called from the client side. Check out "curl", which gives you some pretty good control of which method is being called on your web service.

I hope it helps.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!