Difference between SOAP and REST web services
This is one of the most frequently asked question in Java interviews.
While SOAP based web services rely heavily on XML standard, REST web services use the HTTP protocol methods PUT, GET, DELETE and POST for operations. If you haven’t written both kind of web services code then let me tell you first hand that it is very easy to write REST web services without making mistakes. For both SOAP and REST web services, there are frameworks out there in market which make the task of writing the web services simpler.
Another important difference which you should be mentioning in the answer to this question is that while REST web services can be invoked using simple HTTP clients and browser add-on , the invocation of SOAP based web services require some learning curve and creation of XML messages. The use HTTP helps web developers who may not have got much chance to play with XML.
1. REST can be consumed by any client e.g. Java, C++, Python client and even a web browser with Ajax and JavaScript.
2. REST is lightweight as compared to SOAP, it doesn't require CPU consuming XML parsing and it also consumes less bandwidth because unlike SOAP, REST doesn't require a SOAP header for every message.
3. SOAP is an old technologies, all modern technical giant are using REST e.g. Google, Twitter, and Flickr.
4. REST is easy to learn, its just nouns and verbs. If you already know HTTP methods then its even easier.
5. Java has excellent support for RESTFul web services, well it also has good support for SOAP web services but you have lots of choices here e.g. Jersey, RESTLet etc.
That's all about difference between REST and SOAP Web Service in Java. Its's one of the most frequently asked questions on Java web service topic. Since REST is the technology which is right now dominating web service space, its also important to know the pros and cons REST style of web service provides over good old secure SOAP web services.
Why REST is better than SOAP?
Now that you know some differences between REST and SOAP web services, let's summarize our reasons of why REST is better choice for modern day web service requirement :1. REST can be consumed by any client e.g. Java, C++, Python client and even a web browser with Ajax and JavaScript.
2. REST is lightweight as compared to SOAP, it doesn't require CPU consuming XML parsing and it also consumes less bandwidth because unlike SOAP, REST doesn't require a SOAP header for every message.
3. SOAP is an old technologies, all modern technical giant are using REST e.g. Google, Twitter, and Flickr.
4. REST is easy to learn, its just nouns and verbs. If you already know HTTP methods then its even easier.
5. Java has excellent support for RESTFul web services, well it also has good support for SOAP web services but you have lots of choices here e.g. Jersey, RESTLet etc.
That's all about difference between REST and SOAP Web Service in Java. Its's one of the most frequently asked questions on Java web service topic. Since REST is the technology which is right now dominating web service space, its also important to know the pros and cons REST style of web service provides over good old secure SOAP web services.
No comments:
Post a Comment