Understand WebService SOAP, Restful, HTTP (post, get) requests

The advantages and disadvantages of the two implementations of Webservice (SOAP, Restful) and HTTP (post/get) direct requests, and how to judge which one to use.

HTTP-GET 和 HTTP-POST

HTTP-GET and HTTP-POST are standard protocols , they use HTTP ( Hypertext Transfer Protocol ) verbs to encode parameters and pass parameters as name/value pairs, and also use associated request semantics. Each protocol consists of a series of HTTP request headers. The HTTP request headers and some other information define what the client requests from the server, and which server responds with a series of HTTP response headers and the requested data.
Note: A predicate is a process in which the evaluation of a conditional expression returns true or false.

HTTP-GET passes its parameters as URL-encoded text using the MIME type application/x-www-form-urlencoded (which will be appended to the URL of the server handling the request) . The appended parameters are also known as query strings. Note: URL encoding is a form of character encoding that ensures consistent text in passed parameters. For example, spaces are encoded as %20, and other symbols are converted to %XX, where XX is the ASCII (or ISO Latin-1) value of the symbol expressed in hexadecimal.

Like HTTP-GET, HTTP-POST parameters are also URL-encoded. However, the name/value pairs are passed inside the actual HTTP request message , not as part of the URL.

Our daily websites and systems use this form to access our applications.

Web Service(SOAP)

One of the most basic purposes of Webservice is to provide the ability to work together with different application systems on different platforms.
Web service is an application program that exposes (opens) an API that can be called through the Web to the outside world .

SOAP is a simple XML-based lightweight protocol for exchanging structured and typed information on the web.
The soap request is a special version of HTTP POST , which follows a special xml message format. Content-type is set to: text/xml Any data can be xmlized.

Restful

REST (Representational State Transfer) is a lightweight Web Service architecture that can be fully implemented through the HTTP protocol. Its implementation and operation are more concise than SOAP and XML-RPC, and the cache can be used to improve the response speed, and its performance, efficiency and ease of use are superior to the SOAP protocol. The operations of the REST architecture on resources include obtaining, creating, modifying and deleting resources, which correspond to the GET, POST, PUT and DELETE methods (Verb) provided by the HTTP protocol.

The difference between SOAP and HTTP

Why learn web service?

Most of the external interfaces will implement the web service method instead of the http method. If you don't know how, there is no way to connect. Is web service better than http (post/get)?

  1. The methods and required parameters implemented in the interface are clear at a glance
  2. Don't worry about capitalization
  3. Don't worry about the Chinese url encode problem
  4. There is no need to declare authentication (account, password) parameters multiple times in the code
  5. Pass parameters can be arrays, objects, etc...

Is web service faster than http (post/get)?

Due to xml parsing, the speed may be reduced.

Can web service be replaced by http (post/get)?

It is completely possible, and the current open platforms are all implemented with HTTP (post/get).

The difference between Restful and SOAP

  • Security SOAP would be better than restful
  • Efficiency and ease of use (REST is even better)
  • Maturity (in general SOAP is superior to REST in maturity)

Guess you like

Origin blog.csdn.net/wu_zhiyuan/article/details/130637022