Difference of http webservice socket

1 Data transmission mode
1.1 Definition and characteristics of socket transmission The
    so-called socket is usually called "socket", which realizes the physical connection between the server and the client, and carries out data transmission. There are mainly two protocols, udp and tcp . The socket is at the transport layer of the network protocol .
    udp protocol: broadcast data transmission without data verification
    tcp protocol: transmission control protocol, a connection-oriented protocol that provides user processes with a reliable full-duplex byte stream.

   Features of socket transmission:
   Advantages
   1) The transmission data is byte-level , the transmission data can be customized , and the amount of data is small (for mobile phone applications: low cost)
   2) The data transmission time is short and the performance is high
   3) It is suitable for client and server Real-time exchange of information between terminals
   4) It can be encrypted and has strong data security
   Disadvantages:
   1) The transmitted data needs to be parsed and converted into application-level data
   2) The development level of developers is required to be high
   3) Compared with http protocol transmission , increasing the amount of development

 The scope of application of
  socket transmission is based on the characteristics of socket transmission: The  socket transmission method is suitable for applications with high requirements for transmission speed, security, real-time interaction, and cost, such as online games, mobile phone applications, and internal bank interactions.

 

1.2 Definition and characteristics of transmission based on http protocol

   At present, there are mainly http protocol  and soap protocol (web service) based on http protocol. The common methods are http post and get requests, and web services.

   Transmission characteristics based on http protocol

   Advantages:
   1) The application-level interface is easy to use
   2) The programmer's development level is not high, and the fault tolerance is strong.
   Disadvantages:
   1) The transmission speed is slow and the data packet is large (the http protocol contains auxiliary application information)

   2) Such as real-time interaction, the server performance pressure is high .

   3) Poor data transmission security

   Scope of application
   based on http protocol transmission Based on the characteristics of http protocol transmission: http protocol based transmission mode is suitable for applications that do not require very high transmission speed and security, and require rapid development. Such as company oa system, Internet service, etc.

 

The difference between WebService and Socket

Difference 1.

Socket is a transport layer protocol based on TCP/IP.

WebService transmits data based on the HTTP protocol, which is an application layer protocol based on TCP.

Difference 2.

The WebService uses the HTTP-based SOAP protocol to transmit data, and the interface supports object-oriented. Finally, the WebService will serialize the object and transmit it through the stream.

The Socket interface transmits directly through streams and does not support object orientation.

Socket is at the transport layer, and WebService is at the application layer. . http protocol is based on socket, in addition, web service is based on http protocol and soap.

【in conclusion】

WebService uses SOAP protocol for transmission, and the bottom layer is based on Socket communication.

WebService does not need to deal with the sending and receiving of data streams, and is a cross-platform object-oriented remote invocation technology.

 Both socket and webservice have the advantages of cross-platform, but:  Socket is low-level and has high efficiency, but the development cost is high.         Webservice is inefficient, but the development cost is low.
       

[Socket and WebService application scenarios]

[ socket ]

The immediacy of socket communication is better than http . Socket is based on the transport layer, http is based on the application layer, socket is the basis for all communication through ports (including http)

Socket is the fourth layer (transport layer) in the OSI 7-layer protocol. Socket is just an interface abstracted by the transport layer on the basis of OS.

Suitable for transferring large amounts of data.

Disadvantages: Since the transmitted data needs to be manually parsed, the interface protocol of socket communication needs to be customized, such as: customizing a string splicing format, or custom XML data, the trouble of customization lies in the interface calling method and interface Servers need to discuss with each other to determine the protocol content of the interface, which is inconvenient.

Advantages: suitable for transferring large amounts of data.

The very important SOAP is a protocol of the application layer, and the Http protocol that SOAP usually binds is also a protocol of the seventh layer. Sockets are efficient, but are easily blocked by firewalls .

socket, provides the realization of tcp/ip or udp communication, if it is a standard server, such as a download server; or a program for voice communication, or video, file transfer ... these can only be used socket.
It will be very annoying to simply use socket to write, you have to deal with various things, protocol encoding and decoding, etc., so in this case, mina, netty or grizzly are recommended.

 

[ WebService ]

WebService follows the standard SOAP protocol. The content format of the SOAP protocol is fixed. The content transmitted by the SOAP protocol is XML data. Since the WebService is based on HTTP, it is easy to understand SOAP=HTTP+XML. Because the WebService needs to be serialized twice, it leads to Its transmission speed is slow, and it is suitable for scenarios with no performance requirements and a small amount of data transmission . It is recommended to use WebService on the public interface.

Webservice is based on the HTTP protocol, so it can use the existing very mature Web cluster to provide high load, which is very difficult for sockets compared to the same period.
Webservice is inseparable from the web server (apache), which is a server that provides http communication on the public network. Webservice is generally built on the web server for others to call.

The efficiency of WebService is almost, and it is generally not blocked by the firewall when using the http protocol.

Webservice, based on the http protocol, is a communication method with xml as the carrier.
    Advantages: One is intuitive, two are standard, and it is also convenient for the interaction of heterogeneous systems .
    If you want to provide an interface for external business access, you may need access to various heterogeneous systems such as browsers and clients in various languages, which is the first choice.

 

 

I don't think it's very appropriate to compare sockets with http, webservices, etc. The so-called http is just a packaging of sockets, and the latter is more low-level.

 

Guess you like

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