开发者

Difference between SOAP webservice and RESTFUL webservice

开发者 https://www.devze.com 2023-04-07 13:02 出处:网络
I am new to Java.I know that there are two types of web service SOAP Webservice. RESTful Webservice. can any one please tell me what is the basic difference between both of them.And in which situa

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 situat开发者_如何学Goion the SOAP Webservice is created and in which situation RESTful Webservice is created.

Thank You,


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号