Web API
- REST - Representational State Transfer
- SOAP - Simple Object Access Protocol
- GraphQL - A query language for your API
difference between REST and SOAP
Feature | REST | SOAP |
---|---|---|
Protocol | Can use any protocol but typically uses HTTP/HTTPS | Uses HTTP, SMTP, TCP, and more |
Standards | No official standard, uses HTTP methods (GET, POST, PUT, DELETE) | Official standard by W3C |
Performance | Lightweight, less data overhead | Heavyweight, more data overhead due to XML usage |
Message format | Can use multiple formats (JSON, XML, etc.) | Uses XML |
Security | Uses web security standards | Uses WS-Security which is more robust |
Transaction support | No official support | Official support |
State management | Stateless | Stateful |
说明:
- SOAP by itself is a protocol, but it can use any protocol to transport its messages, REST is not a protocol, it typically uses HTTP/HTTPS.
- REST is stateless which means
each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client.