Why isn't SOAP-based web service RESTful?
REST and SOAP are not equivalent concepts.
REST:
- Depends on one transport protocol (HTTP).
- Makes full use of the specific features of that protocol (verbs GET, POST, PUT, DELETE, caching, headers, and predefined error codes).
- Says nothing about the format of the messages passed back and forth. However, since the HTTP verb and URL already define the action to take, the message body must therefore contain only the data.
- Message security is provided by the transport protocol (HTTPS), and is point-to-point only. If you want to secure the message end-to-end, you have to do it yourself.
- Originally intended for simple CRUD operations on objects.
SOAP:
- Independent of the transport protocol (could be HTTP, FTP, TCP, UDP, named pipes, shared memory or even email).
- Requires only that the transport protocol be able to send and receive text (e.g. on HTTP, only the POST verb is used).
- Strictly defines the format of the messages passed back and forth. A SOAP message contains the data, the action to perform on it, the headers, and the error details in case of failure.
- Message security is provided by the WS-* standards, and is end-to-end.
- Originally intended for arbitrary RPC calls.
Items 2 and 3 in the above lists are the main points of incompatibility.
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 conforms to nothing more than the http protocol.
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.