webservice interface and HTTP interface

What is webservice interface

Web Service is an application. It does not depend on language or platform. It can realize mutual calls between different languages ​​(through information in xml format) and interact between network applications based on the HTTP protocol through the Internet. Web Service technology enables different applications running on different machines to exchange data or integrate with each other without the need for additional, specialized third-party software or hardware. Applications implemented according to Web Service specifications can exchange data with each other regardless of the language, platform or internal protocol they use . Web Service is a self-describing, self-contained available network module that can perform specific business functions. Web Services are also easy to deploy because they are based on common industry standards and existing technologies, such as XML information. Web Services reduce the cost of application interfaces. Web Service provides a common mechanism for the integration of business processes across an entire enterprise or even between multiple organizations.

The following is an example of a webservice interface

发送报文:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://WebXml.com.cn/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:getSupportCity>
         <!--Optional:-->
         <web:byProvinceName>北京</web:byProvinceName>
      </web:getSupportCity>
   </soapenv:Body>
</soapenv:Envelope>

返回报文:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <getSupportCityResponse xmlns="http://WebXml.com.cn/">
         <getSupportCityResult>
            <string>北京 (54511)</string>
            <string>上海 (58367)</string>
            <string>天津 (54517)</string>
            <string>重庆 (57516)</string>
         </getSupportCityResult>
      </getSupportCityResponse>
   </soap:Body>
</soap:Envelope>

Through this example, the webservice interacts with network applications based on the HTTP protocol through the Internet. Software services provided over the Web via SOAP, described using WSDL files, and registered via UDDI.

What is HTTP interface

The Http protocol is based on the TCP protocol. When the browser needs to obtain web page data from the server, it will issue an Http request. Http will establish a connection channel to the server through TCP . When the data required for this request is completed, Http will immediately disconnect the TCP connection. This process is very short. Therefore, the HTTP connection is a short connection and a stateless connection.
The main features of the HTTP protocol can be summarized as follows:
1. Supports client/server mode.
2. Simple and fast: When a client requests a service from the server, it only needs to transmit the request method and path. Commonly used request methods are GET, HEAD, and POST. Each method specifies a different type of contact between the client and the server. Due to the simplicity of the HTTP protocol, the program size of the HTTP server is small and the communication speed is very fast.
3. Flexible: HTTP allows the transmission of any type of data object. The type being transferred is marked by Content-Type.
4. No connection: The meaning of no connection is to limit each connection to only process one request. After the server processes the client's request and receives the client's response, it disconnects. This method saves transmission time.
5. Stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory ability for transaction processing. The lack of status means that if subsequent processing requires the previous information, it must be retransmitted, which may result in an increase in the amount of data transferred per connection. On the other hand, the server responds faster when it does not need previous information.
Insert image description here
1. Request line

The request line consists of three fields: the request method field, the URL field, and the HTTP protocol version field, which are separated by spaces. For example, GET /index.html HTTP/1.1.

The request methods of the HTTP protocol include GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, and CONNECT.
The most commonly used methods are:
GET method: When accessing a web page by entering the URL in the address bar of the browser, the browser uses the GET method to obtain resources from the server.

The POST method requires the requested server to accept the data attached to the request and is often used to submit forms.
2. Request header

The request header consists of keyword/value pairs, one pair per line, and the keywords and values ​​are separated by English colon ":". The request header informs the server about the client's request. Typical request headers are:

User-Agent: The browser type that generated the request.

Accept: List of content types recognized by the client.

Host: The requested host name, allowing multiple domain names to be at the same IP address, that is, a virtual host.

3. Blank line

The last request header is followed by a blank line, carriage return and line feed characters are sent to notify the server that there are no more request headers to follow.
4. Request text

The request data is not used in the GET method, but in the POST method. The POST method is suitable for situations where customers are required to fill out a form. The most commonly used request headers related to request data are Content-Type and Content-Length.

HTTP response message

After receiving and interpreting the request message, the server returns an HTTP response message.

The HTTP response also consists of three parts: status line, message header, and response body.

Article reference link

webservice interface and HTTP interface study notes

Guess you like

Origin blog.csdn.net/yx1166/article/details/123904135