Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SOAP webservice and RESTFUL webservice

I am new to Java.I know that there are two types of web service

  1. SOAP Webservice.
  2. RESTful Webservice.

can any one please tell me what is the basic difference between both of them.And in which situation the SOAP Webservice is created and in which situation RESTful Webservice is created.

Thank You,

like image 689
Kri Avatar asked Sep 26 '11 20:09

Kri


2 Answers

At a very basic level , SOAP is a messaging protocol , REST is a design philosophy , not a protocol. When you base a WebService on a SOAP protocol , you basically comply with SOAP rules of creating a Service Request , posting the request to server , receiving the request at server , processing the request and returning the results as a SOAP message.SOAP does not talk about the exact manner in which client benefits from the service, nor about how to design the client itself ( apart from the message it is posting ), it only tells how a message from client can be sent to service and back.

REST is short for REpresentational State Transfer. It does not specify the rules to create a message and post it to server. You can do this by simple HTTP protocol. What REST specifies is the manner in which client and server manage their states so that they become useful to the client -server communication. Here , you are more focussed on designing the states of clients and servers rather than the messages they are exchanging.

like image 101
Bhaskar Avatar answered Oct 29 '22 15:10

Bhaskar


As the first answer allready explains, SOAP Webservices and REST Webservices differ in various points.

SOAP:

  • you define your interface in a .wsdl file, which describes exactly which input parameters are expected and how the return values will look like
  • there are tools to generate the .wsdl files out of java class hirarchies. JAXB for example
  • there are also tools to generate java objects/classes as part of eclipse for example (don't know the name in the moment).
  • SOAP is very strict. Every request is validatet against the wsdl before processing.

A good but not so easy to start with framework for SOAP WS is Apache CXF

REST (no hands on experience up to now, feel free to correct and improve ;) ):

  • a way to access a webserver or web application to retrieve data from or send to it.
  • it's only negotiated, how it is accessed.
  • common is something like this http://server.domain.com/app/type/id=123 to retrieve object of type type with id=123
  • very intuitive, but no automatic validation of requests.
  • ...

I am sure, there are several other points I missed. But I think it's a usefull start.

like image 28
andreas Avatar answered Oct 29 '22 14:10

andreas