Protocol和Json Wire Protocol有什么区别 [英] What is the difference between Protocol and Json Wire Protocol

查看:980
本文介绍了Protocol和Json Wire Protocol有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

协议:一种用于定义通过网络交换数据的方法的标准. 如果浏览器要与服务器通信,则必须创建一个HTTP请求并将该HTTP请求发送到服务器以传达其资源和选项请求.服务器接收请求并对其进行处理,并进行必要的操作,并创建HTTP响应以发送到浏览器.浏览器在创建HTTP请求时必须遵循HTTP规范.服务器在创建HTTP响应时还必须遵循HTTP规范.这是浏览器和服务器之间以标准方式进行通信的方式,从而通过遵循HTTP协议来避免冲突.

Protocol: A standard to define a method of exchanging data over a network. If a browser wants to communicate with a server, it has to create an HTTP request and send that HTTP request to the server to convey its request of resources and options. The server receives the request and process it and do the needful and create an HTTP response to send to the browser. The browser has to follow the HTTP specification in creating the HTTP request. The server also has to follow the HTTP specification in creating the HTTP response. This is how the communication between the browser and the server happens in a standard way to avoid conflicts by following the HTTP protocol.

Json Wire Protocol :客户端具有必须发送到服务器的对象.客户端将此对象转换为JSON对象,并将其发送到服务器.服务器解析JSON对象,并将其转换回对象以供使用.服务器将响应对象转换为JSON对象,然后将其发送回客户端.然后,客户端将JSON对象转换为要使用的对象.

Json Wire Protocol: A client has an object that has to be sent to a server. The client converts this object into a JSON object and sends it to the server. The server parses the JSON object and converts it back to object for use. The server converts the response object into a JSON object and sends it back to the client. The client then converts the JSON object to object for use.

为什么将后者称为 Json Wire Protocol ?

推荐答案

您对协议 JsonWireProtocol 都非常正确.在这一点上,值得一提的是,与浏览器通信的 WebDriver 的所有早期实现,或RemoteWebDriver服务器应使用通用的有线协议.该有线协议使用 JSON .

You are pretty correct both about Protocol and JsonWireProtocol. At this point it is worth to mention that, earlier all implementations of WebDriver that communicated with the browser, or a RemoteWebDriver server shall use a common wire protocol. This wire protocol defines a RESTful web service using JSON over HTTP.

JSON Wire Protocol 是有关自动化行为(例如单击或键入或您实际上要对自动化脚本执行的任何操作都将映射到selenium或appium或HTTP请求和响应.该协议将假定WebDriver API已被扁平化",但是期望客户端实现将采用更面向对象的方法,如现有Java API所示.有线协议是在命令"和响应"的请求/响应对中实现的.

JSON Wire Protocol is an abstract specification of how automation behavior like clicking or typing or whatever you actually want to do with your automation script is mapped to selenium or appium or HTTP requests and response. The protocol will assume that the WebDriver API has been "flattened", but there is an expectation that client implementations will take a more Object-Oriented approach, as demonstrated in the existing Java API. The wire protocol is implemented in request/response pairs of "commands" and "responses".

JSON(JavaScript对象表示法)是一种轻量级格式,用于客户端和服务器之间的数据交换.应用程序使用JSON对象在网络世界之间相互发送和接收数据. JSON数据结构是行业标准,可用于以 Key&值对.有人说,它是 XML 的非常不错的选择.我们可以将JSON文件保存为.json扩展名.

JSON (JavaScript Object Notation) is a lightweight format for data exchange between client and server. Applications use JSON objects to send and receive data between each other in the web world. JSON data structure is industry standard and can be used for sending and receiving data as Key & Value pair. Some people say its a very nice alternative for XML. We can save JSON files as .json extension.

一个简单的json文件如下所示,并且有许多在线编辑器,可用于编辑和验证JSON结构

A simple json file looks like below and there are many online editors which can be used to edit and verify JSON structure.

{
 "Student":{
   "FirstName":"Pawan",
   "LastName":"Garia",
   "IdNumber":"12345",
   "City" : "New Delhi",
   "EmailID" : "email@gmail.com" }
}

为什么 JSON有线协议首先被使用了吗?

要实现可为我们带来以下好处的客户端-服务器体系结构.

Why JSON Wire Protocol was used in first place?

To implement a client-server architecture which can give us the following benefits.

  • 您可以使用任何编程语言编写测试.
  • 您可以在SauceLabs,BrowserStack或Selenium Grid安装程序等云服务上执行或运行测试.
  • 您不必只在本地计算机上运行测试.
  • 可以使用相同的标准为浏览器创建不同的驱动程序(FirefoxDriver,ChromeDriver)并单独实施.

因此,客户端-服务器的实现需要事先准备一套标准的规范,以便服务器和客户端应根据请求和响应的来龙去脉相互保持同步.就像是彼此交流的语言.因此,我们需要一些通用的规范来解决这种要求,而解决方案就是HTTP.

So client-server implementation requires a standard set of the specification beforehand so that Server and Client should be in sync with each other in term of what is coming and going on request and response. It’s something like a language of communication with each other. So we need some common specification to solve this kind of requirement and the solution was HTTP.

HTTP是Web的标准,可以作为规范的良好基础.每种编程语言都具有良好的HTTP库,可用于创建客户端和服务器以进行请求和响应电话.

HTTP is a standard for web and can be a good base for the specification. Every programming language has a good HTTP libraries which can be used for creating client and server for request and response calls.

HTTP请求和响应通常由GET和POST请求组成,因此不在本讨论范围之内.

HTTP request and response are generally made of GET and POST requests which is out of scope for this discussion.

的角度来看, JSON Wire Protocol 现在已过时,并且

From Selenium perspective, JSON Wire Protocol is obsolete now and the WebDriver W3C Living Document is the new implementation.

这篇关于Protocol和Json Wire Protocol有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆