XMLHTTP与ServerXMLHTTP之间的差异 [英] Differences between XMLHTTP and ServerXMLHTTP

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

问题描述

我正在尝试编写一个可以从Web服务获取数据到Excel的Excel加载项。



要使用它,用户只需要键入由加载项提供的函数名称。我发现两篇文章在VBA中实现HTTP请求: XMLHTTP ServerXMLHTTP



我很难使用它们。我不知道要使用哪一个。 XMLHTTP和ServerXMLHTTP之间有什么区别?

解决方案

Davuz,





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



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



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



从技术立场上,XMLHTTP对象使用WinInet(Windows Internet Explorer)的功能,而ServerXMLHTTP对象使用客户端堆栈。 WinInet dll是Windows互联网协议管理的骨干,dll用于处理HTTP,HTTPS,FTP和类似请求。



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



简而言之,除了上述注释的信息之外,XMLHTTP对象通常用于以某种方式请求信息并使用它,通常为客户。同样有用但通常不同的是,ServerXMLHTTP对象可以用于请求数据,甚至以相对有效的方式发送数据或甚至将接收到另一个应用程序传递给另一个应用程序。这通常用于需要实时响应的业务应用程序,或者通过一系列请求向客户提供数据,也许是这些请求中内置的条件,而且还有更多。



希望对两者之间的差异有所了解。在阅读关于使用特定XMLHTTP类型请求的SO问题/答案时,还有更多的内容,以及深入研究MSDN和其他提供VB / VBA和Microsoft Office的Internet / XMLHTTPRequest特定材料文档的站点。 p>

让我知道,如果这有帮助,或者如果你有其他问题/想法,



〜JOL


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

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.

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

解决方案

Davuz,

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

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

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.

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.

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.

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.

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.

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天全站免登陆