I understand RESTful is an architecture style, but what exactly makes SOAP-based web service not count for RESTful?
It's not clear to me which points below (from Wikipedia), is not conformed by SOAP.
- Client-server
- Stateless
- Cacheable
- Layered system
- Code on demand (optional)
- Uniform interface
- Identification of resources
- Manipulation of resources through these representations
- Self-descriptive messages
- Hypermedia as the engine of application state
EDIT: I just came across this which summaries it pretty well.
REST is not RPC, RPC says, "define some methods that do something" whereas REST says, "define some resources and they will have these methods". It is a subtle but vital difference, when given a URI anyone knows they can interact with it via the predefined set of methods and receive standard HTTP responses in return. So given http://www.peej.co.uk/ I know I can issue a GET on it and receive something meaningful back. I may then try a PUT on it to change it and receive a meaningful HTTP error code since I'm not authorised to meddle with it.
SOAP vs REST Web Services
1) SOAP is a protocol whereas REST is an architectural style.
2) SOAP can't use REST because it is a protocol whereas REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
3) SOAP uses services interfaces to expose the business logic whereas REST uses URI to expose business logic.
4) SOAP defines standards to be strictly followed whereas REST does not define too much standards like SOAP.
5) SOAP requires more bandwidth and resource than REST whereas REST requires less bandwidth and resource than SOAP.
6) SOAP defines its own security while RESTful web services inherits security measures from the underlying transport.
7) SOAP permits XML data format only whereas REST permits different data format such as Plain text, HTML, XML, JSON etc.
RESTful web services are heavily preferred over SOAP web services.
SOAP Protocol: SOAP is a protocol which means that it has a defined structure to it.
RESTful API Design involves breaking the system in terms of resources, and providing access to those resources through endpoints (also called operations) defined on the web service's base uris. Access is done using standard HTTP Methods and controlled by an auth mechanism. Configuration for the resource is provided and obtained through request and response with HTTP status codes communicating the status. 1. Resources are the entities that exist in the system being made RESTful. For instance, in case of a blogging website, these can be the blogs, posts and comments. 2. EndPoints or operations provide a mechanism through which these resources can be accessed. For instance, the endpoint to list all the blog posts on a particular blog would be a GET on /blogs/{blogId}/posts. 3. Base URIs define the web uri location where the resources are available through the endpoints. To take a real example, for Google blogger the base_uri is https://www.googleapis.com/blogger/v3. 4. HTTP Methods is where the simplicity of REST lies. In RESTful API design, operations on resources are done through the standard HTTP methods, primarily GET, POST, PUT and DELETE . Other HTTP methods - OPTIONS, HEAD, PATCH are also used in some cases.
Restful : REST is architectural style for building web service using HTTP protocol, where web services are treated as resources and some basic HTTP methods like GET, POST, DELETE are used to identify standard action on resources. RESTful web API (also called a RESTful web service) is a web API implemented using HTTP and the REST principles.
Soap : SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in XML form.
SOAP follows the RPC pattern. A SOAP API describes a series of methods, along with their parameters and return values, that you can call from your code. There's a marshaling step that converts this into it's network representation.
REST is never RPC. A REST API describes a series of resources, along with a set of verbs (typically HTTP's GET, POST, PUT, DELETE) that can act on them.
To answer your question directly: SOAP primarily violates point 6 (it doesn't provide a uniform set of verbs across APIs). It also violates point 2 (the server can maintain state for each client), and as a result point 3 as well (state prevents caching).
One of the objectives of REST is cachability, for that the resource needs to be identified by the uri (query string). In soap the request is posted, therefor for different requests you have the same uri and thus the resource cannot be uniquely identified by the ur
REST and SOAP are not equivalent concepts.
REST:
SOAP:
Items 2 and 3 in the above lists are the main points of incompatibility.