May 19, 2011

REST Web Service Interview Questions

Here I am putting 20 REST questions. Please read some tutorial on REST before taking up these questions. Simply mugging up the answers will not give you the confidence for interview.


Some questions may not be applicable to eveyone. For example if you have used anything else than CXF or RESTLET for building REST web services then the question number 15 may not hold good for you.



If you are unable to get answer to any of the question, do drop a comment, I will be more than happy to get back with the answer...

1) What is a web service?

2) Can I use GET request instead of PUT to create resources?

3) What is the difference between a RESTful web service (on HTTP) and a HTTP Servlet both of which perform the same function?

4) How will you migrate from SOAP web service to RESTfull web service?

5) What is the difference between HTTP POST and PUT requests?

6) What all kind of output formats can one generate using RESTful web service?

7) What all tools have you used to write RESTful web service?

8) Can my web browser be a client to RESTful web service? If yes then how will you generate DELETE request from web browser?

9) What is meant by JAX-WS and JAX-RS?

10) How is JAXB related to RESTful web services?

11) How will you handle synchronization issues when multiple clients try to consume web service simultaneously?

12) Can you describe any one RESTful web service you have written?

13) What will you do when an error code has to be returned to the client
OR
How will you handle application error scenarios in RESTful web service

14) Is it mandatory to use HTTP protocol for performing CRUD operations by a REST based web service?

15) What are the pros and cons of using the RESTLET framework than CXF for writing RESTful web service?

16) Can one RESTful web service be a client to another RESTful web service for performing business operations? Describe with example?

17) Can you generate HTML output from a RESTful web service? How?

18) Can a RESTful web service generate output in various formats based on some parameter received from the client.

19) With a RESTful web service, whose state is getting transferred and how?

20) Who owns the specification for REST web services and how does it get updated to newer versions?


8 comments:

  1. For #2, shouldn't a POST be used to create a new resource instead of a PUT?

    ReplyDelete
  2. In fact both can be used for creating new resources. PUT requires you to know the URL where to PUT and POST does not. Read the following for more clarification:

    http://www.elharo.com/blog/software-development/web-development/2005/12/08/post-vs-put/

    ReplyDelete
  3. Thanks for that!  That makes a lot of sense and, similar to the author, makes the distinction between PUT and POST a lot more clean in my mind.

    ReplyDelete
  4. Could you please give answer to question 3?

    ReplyDelete
  5. While Servlet is specific to the Java/JEE specification but REST is a
    specification which has nothing to the language which provides an
    implementation for this service (web service). Though both can work on
    HTTP and other protocols but pure RESTful web service should conform to HATEOAS.
    While Servlet can provide output in HTML format but RESTful web
    service can provide output in multiple formats like HTML, XML, RSS etc.

    ReplyDelete
  6. Servlets can also provide output in multiple formats, right?with  setContentType(type)?

    Found this explanation online
    'The most obvious difference between Servlet and Web Service is: You access servlet via HTTP while access Web Service via SOAP (Simple Object Access Protocol). But, in fact, you can not directly invoke a servlet, you can only open URL connection and put some parameter to the servlet if the caller is out of your application. And you can not restrict what parameters the caller can put. The caller does not know what parameters your servlet can receive either. So, You'd better use web service to provide API to other applications, the WSDL file of your web service can give the caller enough information to invoke your web service.'

    ReplyDelete
  7. Hi Can you provide the answers to the question

    ReplyDelete
  8. Hi, I collected couple of Restlet interview questions/answers on my blog which all those are through my past experience. You can find them at my blog
    http://java-dvlpr.blogspot.com/2011/08/restful-web-servicesrestlet-faqs.html

    ReplyDelete