首页 > 代码库 > SOAP vs REST

SOAP vs REST

SOAP: Simple Object Access Protocol, it‘s protocol.

REST: Representational State Transfer, it‘s architecture style.

 

SOAP supports many transport protocols: HTTP, SMTP etc. only support XML.

REST also supports many transport protocols, not only HTTP/HTTPS. support XML, JSON etc.

 

SOAP is like desktop-application, we need to define WSDL(IDDL) for client and server to communicate. XML-RPC. Client should have the knowledge.SOAP has additional pre-built WS-Security support. JAX-WS. Since it uses XML, the payload is somewhat larger.

REST is like broswer, we just need to know URI and resource. Resource + Methods. Client has no knowledge about details. Stateless, server will not save any state info. REST uses the security in HTTP if REST over HTTP. JAX-RES

Common HTTP Method: Get/Put/Post/Delete. These methods are not mapping to CRUD for DB.

Post: not only for create resource, but also for update, and any other non-standardized operations.

Put: replace resource, just ignore the current state. Replace the whole resource.

Patch: partial update, it will base on current state to just apply diff.

REST must adhere to HATEOAS(Hypermedia as the engine of application state). The available operations are returned in link instead of documentation. Client enters a REST application through a simple URL instead of fixed interfaces or WSDL.

 

SOAP vs REST