TCP/IP, Http/Soap Protocol-Basic Understanding

         The reason for writing this article is to develop an interface at work and use the Soap protocol. Further understanding is needed on why Soap is used and what it has to do with the Http protocol and Tcp/Ip protocol that are often heard and touched.

    1. First of all, let’s introduce the basic concepts of the three protocols respectively.

    Refer to Baidu Encyclopedia:

    HTTP, Hypertext Transfer Protocol. It is the most widely used network protocol on the Internet. All WWW documents must comply with this standard. HTTP was originally designed to provide a way to publish and receive HTML pages.

    SOAP, Simple Object Access Protocol. It is a protocol specification for exchanging data. It is a lightweight, simple, and XML-based (a subset of the standard general markup language) protocol. It is designed to exchange structured and solidified information on the WEB. .

    TCP/IP protocol, Transmission Control Protocol/Internet Protocol, also known as network communication protocol, is the most basic protocol of the Internet and the basis of the Internet Internet network. It consists of the IP protocol of the network layer and the TCP protocol of the transport layer. TCP/IP  defines the standard for how electronic devices connect to the Internet and how data is transferred between them.
    In layman's terms: TCP is responsible for discovering problems with transmission, and as soon as there is a problem, it sends a signal to request retransmission until all data is safely and correctly transmitted to the destination. IP specifies an address for each networked device on the Internet.

    Through these three basic concepts, we also have a preliminary understanding of the three protocols, at least understand what they do: Http: accept and publish HTML; Soap: exchange information on the web; TCP/IP: data transmission . To sum up, they are all used for data transmission.

    2. Next, let’s describe these three protocols in detail to see what they transmit and what “magic powers” ​​they have:

   (1) TCP is a connection-oriented communication protocol. A connection is established through a three-way handshake, and the connection is removed when the communication is completed. Since TCP is connection-oriented, it can only be used for end-to-end communication.
    TCP provides a reliable data stream service, and uses the "positive acknowledgment with retransmission" technology to achieve transmission reliability. TCP also uses a method called "sliding window" for flow control. The so-called window actually represents the receiving capability and is used to limit the sending speed of the sender. You can understand it as a "sliding rheostat" that controls resistance in physics.
If there are already sealed TCP packets in the IP packets, then IP will pass them 'up' to the TCP layer. TCP sorts packets and checks for errors, while implementing connections between virtual circuits. TCP packets include sequence numbers and acknowledgments, so out-of-order packets can be sequenced and corrupted packets can be retransmitted.
    TCP sends its information to higher-level applications, such as Telnet servers and clients. Applications in turn send information back to the TCP layer, which then passes them down to the IP layer, device drivers and physical media, and finally to the receiver.
    Connection-oriented services such as Telnet, FTP, rlogin, X Windows, and SMTP require a high degree of reliability, so they use TCP. DNS uses TCP in some cases (to send and receive domain name databases), but uses UDP to convey information about individual hosts.

   (2) The IP layer receives the data packet sent by the lower layer (the network interface layer such as the Ethernet device driver), and sends the data packet to the higher layer---TCP or UDP layer; on the contrary, the IP layer also sends the data packet from the Packets received by the TCP or UDP layer are passed to lower layers.

    IP packets are unreliable because IP doesn't do anything to confirm if the packet was sent in order or if it was corrupted, the IP packet contains the address of the host that sent it (source address) and the host that received it address (destination address).

   (3) The HTTP protocol is a transport protocol for transferring hypertext from a WWW server to a local browser. It can make the browser more efficient and reduce network traffic. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is transmitted, and which part of the content is displayed first (eg, text before graphics).
    HTTP is an application-layer communication protocol between a client browser or a web server. All hypertext information is stored on the Web server on the Internet, and the client needs to transmit the hypertext information to be accessed through the HTTP protocol. HTTP contains commands and transmission information, which can be used not only for Web access, but also for communication between other Internet/intranet application systems, so as to realize the integration of hypermedia access to various application resources.
    The website address we enter in the browser's address bar is called a URL (Uniform Resource Locator). Just like every household has a house number address, every web page also has an Internet address. When you enter a URL in your browser's address box or click a hyperlink, the URL determines the address to browse. The browser extracts the web page code of the site on the web server through the HTTP protocol and translates it into a beautiful web page.

    (4) is an XML-based protocol for exchanging messages, which can be transmitted using HTTP. In fact HTTP is the most common transport tool for SOAP messages. After soap serializes the information to XML, it is packaged and transmitted by means of the http protocol. The transmission method is still tcp or udp.

    It's easy to understand with an analogy. Both tcp and udp are roads. For the time being, consider tcp as general roads, udp highways, soap and http are cars, then soap and http can run on tcp and udp. It is said that soap can be transmitted through http, which means that soap is a car, and http is a truck loaded with cars. The information of soap is loaded into http, and then transported. Of course, the road to take is still tcp or udp.

    It is not very accurate to say that soap can be transmitted through the http protocol. It is more accurate to say that the soap information can be packaged through the http protocol and then transmitted through tcp or udp.

    3、SOAP实例分析

    下面通过一个SOAP实例,来理解一下:

    图1是通信双方规定的参数输入和输出规范:

    

    图2是SoapUI中的参数设置和访问地址:

    

    具体的后台代码就不演示了,简单描述一下:输入输出都是封装好的bean对象。sql直接查出来的数据为List,之后再将一些返回参数和该List一并放入Map,在将Map放入ResponseBean,返回就可以了。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325663234&siteId=291194637