Friday, January 6, 2012

REST Web services Framework interview questions answers

REST web services  has quickly becoming deafacto web services in web world and has almost replaced SOAP based web services which rules the world before. with growing use of REST in web technology space REST is also becoming increasingly important on J2EE and other web development interviews and if you say you know web-service then be prepare for some REST concept related questions. In this article I have put together some of the basic and some advanced REST web service questions together which will be useful to revise the concept before appearing for any REST web service interviews:

This article is in continuation of my earlier post on Interviews like Top Spring Interview Questions and Top StrutsInterview Questions.

Top 10 REST Web services Framework interview questions answers

RESTFul Web Services Interview Questions and Answers

REST Web Service interview questions and Answers J2EEHere are list of my REST Interview questions, helpful for quick review before going for any web services interview on Java J2EE.

1) What is REST and RESTful web services ?
this is the first REST interview question on most of interviews as not everybody familiar with REST and also
start discussion based on candidates response. Anyway REST stands for REpresentational State Transfer (REST) its a relatively new concept of writing web services which enforces a stateless client server design where web services are treated as resource and can be accessed and identified by there URL unlike SOAP web services which were defined by WSDL.

Web services written by apply REST Architectural concept are called RESTful web services which focus on System resources and how state of Resource should be transferred over http protocol to a different clients written in different languages. In RESTful web services http methods like GET, PUT, POST and DELETE can can be used to perform CRUD operations.

2) What is differences between RESTful web services and SOAP web services ?
Though both RESTful web series and SOAP web service can operate cross platform they are architecturally different to each other, here is some of differences between REST and SOAP:

1) REST is more simple and easy to use than SOAP
2) REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
3) REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDA's.
4) REST supports different format like text, JSON and XML while SOAP only support XML.
5) REST web services call can be cached to improve performance.

3) What is Restlet framework ?
Restlet is leading RESTful web framework for Java applications is used to build RESTFul web services it has two part Restlet API and a Restlet implementation much like Servlet specification. There are many implementation of Restet framework available you just need to add there jar in your classpath to use them. By using Restlet web framework you can write client and server.

4) What is Resource in REST framework ?
it represent a "resource" in REST architecture. on RESTLET API it has life cycle methods like init(), handle() and release() and contains a Context, Request and Response corresponding to specific target resource. This is now deprecated over ServerResource class and you should use that. see Restlet documentation for more details.

5) Can you use Restlet without any web-container ?
Yes, Restlet framework provide default server which can be used to handle service request in web container is not available.

6) What is difference between Restlets and Jersey ?
This REST web service interview questions is open for you all, post you answer in comment section.

7) What is RESTEasy ?
RESTEasy is another REST framework introduced in JBoss Application Server. This was rather easy REST interview questions. you can answer in detail only if you have used this or working in JBoss.

8) What are the tools used for creating RESTFull web services ?
You can use AJAX(Asynchronous JavaScript with XAML) and Direct Web Removing to consume web serives in web application. Both Eclipse and NetBeans also supported development of RESTFul services.

9) How to display custom error pages using RestFull web services ?
In order to customize error you need to extend StatusService and implement getRepresentation(Status, Request, Response) method with your custom code now assign instance of your CustomStatusService to appropriate "statusService property".

10) Which HTTP methods are supported by RestFull web services ?
Another common REST interview questioning RESTFul web service each Resource supports GET, POST, PUT and DELETE http methods.GET is mapped to represent(), POST - acceptRepresentation(), PUT- storeRepresentation and DELET for rmeoveRepresentation.

11) What is difference between top-down and bottom-up approach of developing web services ?
In top-down approach first WSDL document is created and than Java classes are developed based on WSDL contract, so if WSDL contract changes you got to change your Java classes while in case of bottom up approach of web service development you first create Java code and then use annotations like @WebService to specify contract or interface and WSDL field will be automatically generated from your build.

12) What happens if RestFull resources are accessed by multiple clients ? do you need to make it thread-safe?
Since a new Resource instance is created for every incoming Request there is no need to make it thread-safe or add synchronization. multiple client can safely access RestFull resources concurrently.

That’s all on REST interview questions , I will add couple of  more REST Interview questions whenever I got them from my friend circle.

Some Interview questions article you may like

Do you like Books?
If you love to read books here are few Java titles which is worth of money :
Please vote +1 or consider sharing if your like this article

4 comments:

Anonymous said...

Appreciate if you share some article with respect to REST webservices.

Anonymous said...

Your Articles are very useful..Appreciate if you could post few articles regarding REST framework.

Thank you

Anonymous said...

This article is riddled with errors and inconsistencies...

To point out a few:
- The RESTful architecture is not a 'relatively new concept' it was developed in parallel with HTTP. Maybe you mean it has increased in popularity for web services?
- It focuses on resources, not system resources
- It is simpler by design but not necessarily simpler to use - SOAP has a lot of tooling for quick generation of WSs
- "REST uses HTTP protocol for producing or consuming web services while SOAP uses XML." Well, no, more often than not SOAP uses HTTP as its transport layer. Requests to RESTful web services can be encoded in XML.
- And as far as thread safety, this should absolutely be a concern. A 'resource' in rest-speak is the noun - a customer, a receipt, a product and while the controller handling the request might have a new controller instance to handle each request, each of the services called by the controller to save or load these resource representations should be checked for thread safety. At some point you will probably query a database and you wont have an instance of your database for every request...

Anonymous said...

HI can u pls tell me what is the difference between RESTful webservices and HttpServlet.
I didn't see any difference between these two.
Just extra annotations.

thanks a lot
Peter

Post a Comment

What is this blog about

This blog is about my experience in Java, Tibco Rendezvous and FIX protocol. FIX is a technology which is used to build equity trading system and heavily used in electronic trading , high frequency trading and Algorithmic trading, so on most of Investment bank job you need to know FIX Protocol on the other hand Tibco Rendezvous is used to implement messaging backbone on many big commercial and global banks. This blog help you to get clear any FIX protocol job interview. It also includes Java and Tibco Rendezvous article written for new user mainly my experience in my own word.