XMLHTTP 和 ServerXMLHTTP 之间的区别 [英] Differences between XMLHTTP and ServerXMLHTTP

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

问题描述

我正在尝试编写一个 Excel 插件,它可以将来自网络服务的数据导入 Excel.

I'm trying to write an Excel add-in that can get data from a web service into Excel.

要使用它,用户只需键入插件提供的函数名称.我发现了两篇在 VBA 中实现 HTTP 请求的文章:XMLHTTPServerXMLHTTP.

To use it, the user just needs to type a function name provided by the add-in. I found two articles implementing HTTP requests in VBA: XMLHTTP and ServerXMLHTTP.

我很难使用它们.我不知道该用哪一个.XMLHTTP 和 ServerXMLHTTP 有什么区别?

I have difficulty with using them. I don't know which one to use. What are the differences between XMLHTTP and ServerXMLHTTP?

推荐答案

Davuz,

Tim 和 Jay 都提供了出色的上下文和简洁的评论.我将简单地添加一些内容并尝试提供一些上下文.

Both Tim and Jay provide excellent context and succinct comments. I will simply add a bit and try to give some context.

本质上,XMLHTTP 对象用于创建一个 XMLHttpRequest,用于从网站/网络服务器/网络服务中请求数据.有关详细信息,请参阅维基百科链接:http://en.wikipedia.org/wiki/XMLHttpRequest

In essence, the XMLHTTP Object is used to create an XMLHttpRequest, which is used to requisition data from a website/webserver/web service. See the wikipedia link for further details: http://en.wikipedia.org/wiki/XMLHttpRequest

一般来说,XMLHTTP 通常在作为客户端与服务器进行通信时使用 - 例如,当您使用应用程序向 Web 服务发出请求时.XMLHTTP 对象还用于各种以客户端为中心的传输方法,例如文件传输协议 (FTP)、url 缓存和其他有用的工具.简而言之,XMLHTTP 对象用于向某种服务器发出请求并请求客户端感兴趣的东西,无论是通过 FTP 连接访问服务器、存储库中的一系列文件还是 Web 服务用于处理来自客户端的数据.

In general, XMLHTTP is general used when communicating as a client to a server - such as when you use an application to make a request to a webservice. the XMLHTTP Object is also used for various client-focused methods of transfer, such as File Transfer Protocol (FTP), url caching and other useful tools. In short, the XMLHTTP Object is used to make a request to a server of some sort and request something of interest to the client, whether it is access to a server via a FTP connection, a series of files from a repository, or a webservice for processing data from the client.

相比之下,ServerXMLHTTP 旨在用于服务器之间、应用程序(客户端)之间的通信以及处理来自客户端的请求.虽然 ServerXMLHTTP 对象保持状态处于活动状态——这意味着发送/接收到/从目的地的信息被保留以用于当前连接中的未来数据事务——它也不主动支持某些 XMLHTTP 功能,例如URL 缓存、自动代理服务器的发现、HTTP/1.1 分块、离线支持以及对 Gopher 和 FTP 协议的支持",用于 ServerXMLHTTP 对象使用的 http 客户端堆栈.

By contrast, the ServerXMLHTTP is intended for communicating between servers, to applications (clients) and for processing requests from clients. While the ServerXMLHTTP Object keeps the state active - meaning that the information sent/received to/from a destination is retained for future data transactions in the current connection - it also does not actively support certain XMLHTTP functions, such as "URL caching, auto-discovery of proxy servers, HTTP/1.1 chunking, offline support, and support for Gopher and FTP protocols" for the http client stack used by the ServerXMLHTTP object.

从技术角度来看,XMLHTTP 对象使用 WinInet (Windows Internet Explorer) 来实现其功能,而 ServerXMLHTTP 对象使用客户端堆栈.WinInet dll 是 Windows 互联网协议管理的支柱,该 dll 用于处理 HTTP、HTTPS、FTP 和类似请求.

From a technical standpoint, the XMLHTTP Object uses WinInet (Windows Internet Explorer) for its functionality, while the ServerXMLHTTP Object uses a client stack. The WinInet dll is the backbone of the Windows internet protocol management, and the dll is used for handling HTTP, HTTPS, FTP and similar requests.

相比之下,当 ServerXMLHTTP 对象创建一个新的客户端 http 堆栈时 - 这本质上是一个 HTTP 客户端的单独会话".使用单独的会话意味着 ServerXMLHTTP 对象的多个实例可能在任何给定时间处于活动状态 - 取决于内存和套接字连接的可用性.

By contrast, when the ServerXMLHTTP Object creates a new client http stack - which is an essence a separate "session" of a HTTP client. The use of a separate session means that multiple instances of the ServerXMLHTTP Object may be active at any given time - depending on memory and availability of socket connections.

所以,简而言之 - 除了上面评论中的信息之外,XMLHTTP 对象通常用于请求信息并以某种方式使用它,通常作为客户端.同样有用但通常不同的使用方式,ServerXMLHTTP 对象可用于以相对有效的方式请求数据、发送数据或什至将接收到的数据传递给另一个应用程序到另一个应用程序.这通常用于需要实时响应的业务应用程序,或者用于在给定一系列请求的情况下向客户提供数据,这些请求可能带有内置条件 - 等等.

So, in a nutshell - in addition to the information from the comments above, the XMLHTTP Object is often used to request information and use it in some way, usually as a client. Similarly useful but often differently used, the ServerXMLHTTP Object may be used to request data, to send data or even to pass received to another application to another application in a relatively efficient manner. This is often used for business applications that require realtime responses, or for providing data to clients given a series of requests, perhaps with conditions built into those requests - and much, much more.

希望这能阐明两者之间的差异.在阅读有关使用特定 XMLHTTP 类型请求的 SO 问题/答案,以及对 MSDN 和其他提供 Internet/XMLHTTPRequest VB、VBA 和 Microsoft Office 特定材料的文档的站点进行更深入的研究时,还有更多信息.

Hopefully that sheds some light on the differences between the two. There is much more to be found when reading SO questions/answers on using specific pieces of XMLHTTP type requests, as well as deeper research into MSDN and other sites providing documentation on internet/XMLHTTPRequest specific materials for VB, VBA and Microsoft Office.

如果这有帮助或者您有其他问题/想法,请告诉我,

Let me know if that helps or if you have other questions/thoughts,

~JOL

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

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