Difference between SOAP web service and RESTFUL web service

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

  • SOAP Webservice.
  • RESTful Webservice.

can someone tell me what is the main difference between the two. And in what situation a SOAP Webservice is created and in what situation a RESTful Webservice is created.

Thanks,

+6
source share
3 answers

As allready's first answer explains, SOAP Webservices and REST web services are different at different points.

SOAP:

  • you define your interface in a .wsdl file that accurately describes what input parameters are expected and what the return values ​​will look like.
  • There are tools for generating .wsdl files from hirarchies of the java class. Jaxb for example
  • There are also tools for creating java objects / classes as part of eclipse, for example (I don’t know the name at the moment).
  • SOAP is very strict. Each request is validatet vs wsdl before processing.

A good, but not so easy, start with the SOAP WS framework is Apache CXF

REST (do not wait until the experience so far, do not hesitate to correct and improve;)):

  • A way to access a web server or web application to retrieve data or send it to them.
  • he only agreed on how he was available.
  • common is something like http://server.domain.com/app/type/id=123 to retrieve an object of type type with id = 123
  • very intuitive, but without automatic query checking.
  • ...

I am sure there are some more points that I missed. But I think this is a good start.

+5
source

At its most basic level, SOAP is a messaging protocol, REST is a design philosophy, not a protocol. When you base WebService on a SOAP protocol, you basically follow SOAP rules to create a service request, send a request to the server, receive a request on the server, process the request, and return the results as a SOAP message. SOAP does not talk about how the client benefits from the service, nor about how to create the client itself (except for the message that it publishes), it only tells how the message from the client can be sent to and from the service.

REST is short for REpresentational State Transfer. It does not define rules for creating a message and sending it to the server. You can do this with the simple HTTP protocol. That REST indicates how the client and server manage their states so that they become useful for client-server interaction. Here you focus more on designing the states of clients and servers, rather than on the messages that they exchange.

+13
source

You could also look behind him; this is a good article on this topic: http://geeknizer.com/rest-vs-soap-using-http-choosing-the-right-webservice-protocol/

+2
source

Source: https://habr.com/ru/post/898109/


All Articles