Table of contents
1. Soap
Soap (Simple Object Access Protocol) is a messaging protocol specification for exchanging structured information in the implementation of web services in the computer networks.
Therefore, (as soap is a protocol) it imposes some build-in rules that can add complexity and overhead, and also lead to long page load times.
The advantage of soap is safety. It supports not only SSL protocol (Secure Sockets Layer)(端到端加密), but also WS-Security protocol (WS = web services) which adds some enterprise security features.
In addition, it build-in the ACID characteristic of database to ensure the consistency and reliability of transactions. This is the reason why banks and payment system use soap.
2. Rest
Rest (Representational state transfer) is a set of web API architecture principles (or style) which suitable for lightweight web services and mobile applications.
The advantage of rest api is more flexible and easy to use.
3. Soap VS Rest
Soap | Rest | |
Concept | Messaging protocol specification. | Web api architecture principles (style). |
Concept | Make data available as services(operation). Me: GetUserInfo. |
Make data available as resources. Eg: UserInfo. |
Services | Back-end services. | Front-end services |
Returned messages type |
XML only | XM, HTML, JSON, PDF, Text, etc. |
Communi- cation methos |
HTTP, TCP, Web Sockets, etc. | HTTP only. |
Message patterns |
Request-reply, one-way. | Request-reply only. |
Cons | 1. Soap consume more bandwidth. 2. Take much effort to implement and is not good for integrate between Web and mobile developers. |
1. Less security. 2. Based on Http protocol only. |
Security | Supports both SSL security and WS-security, which adds some enterprise security features. | Support only point-to-point SSL security. |
Cache | Not support data caches. | Support data caches. |
Reference:
[Dachang interview] Interviewer: You don't even know RESTful, how dare I ask you?
Analysis of the difference between SOAP and REST
Basic difference between SOAP and REST