Difference between SOAP webservice and RESTFUL web

2019-03-10 09:18发布

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,

3条回答
Emotional °昔
2楼-- · 2019-03-10 09:49

You could also have googled for this; this is a nice article on the subject: http://geeknizer.com/rest-vs-soap-using-http-choosing-the-right-webservice-protocol/

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-03-10 09:54

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.

查看更多
干净又极端
4楼-- · 2019-03-10 09:55

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.

查看更多
登录 后发表回答