Thursday, 31 December 2015

7 Difference between REST and SOAP WebService in Java Interview

Difference between REST and SOAP in Java
What is the difference between REST and SOAP Web-service is a very popular question from Java J2EE interviews. I have myself asked this question a number of times. Here I am listing out some of the key differences between REST and SOAP purely from interview perspective i.e. I am only mentioning key points, not going into details. Unless you are doing exclusive work in REST or SOAP Web service, interviewer will not go into deep and if you have done the work already, you probably don't need this list. Anyway, let's see some key difference between REST and SOAP web service in Java.

Difference between SOAP vs REST WebService

1) SOAP is a XML based message protocol while REST is an architectural style protocol.

2) SOAP uses WSDL for communication between consumer and provider, while REST uses XML or JSON to send and received data.

3) SOAP invokes services by calling RPC method while REST simply calls services using HTTP methods via URL Path.

4) SOAP Web services does not return human readable result but REST result is readable because it's just plain XML or JSON.

5) SOAP transfer is over HTTP, but it can also use other protocols such as SMTP, FTP etc, but REST can only use HTTP as transport protocol.

6) Even though you can use SOAP with JavaScript, it's difficult to implement as compared to REST which is very easy to use with JavaScript.

7) REST has better performance over SOAP because its less CPU intensive and requires less resources.

These were some key difference between REST and SOAP Web Service from Java Interview perspective. If you think I have missed any key difference then feel free to add into this list.

Thank you.

No comments:

Post a Comment