Differences between XMLHTTP and ServerXMLHTTP

22,261

Solution 1

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

Solution 2

I just got hit by a difference: When the Web Server (IIS) is configured to allow only Windows Authentication, not anonymous access, the ServerXMLHTTP calls fail with an authentication error whereas the XMLHTTP calls do not. It seems that the XMLHTTP object automatically handles sending the Windows Authentication credentials when needed. I suspect that adding NetworkCredentials to the ServerXMLHTTP object should be the best solution but I could only find Basic Authentication which explicitly passes plaintext uid/pwd (obviously unacceptable).

Solution 3

The ServerXMLHTTP object utilises winhttp where as XMLHTTP utilises wininet.

As wininet parses such matters as authentication and proxy configuration, such problems won't appear like they do when utilising ServerXMLHTTP. However the limited flexibility within XMLHTTP may force you to take-on the additional responsibilities with using ServerXMLHTTP, by having to negotiate server and destination end-point authentication mechanisms, although there are methods within winhttp to assist in this.

When porting the more client based XMLHTTP to the more configurable robust ServerXMLHTTP object and classes, you may wonder why you hadn't done so long ago.

Don't even get me started on the ill fated and now defunct WPAD support in either. :)

Solution 4

What really helped me was that.

After defining Object:

Dim objHTTP As Object

Set objHTTP = createObject("MSXML2.ServerXMLHTTP")
...

Then include these two lines:

' --- Disregard any Proxy Settings and go straight to the IP address

    objHTTP.SetProxy 1
Share:
22,261
Davuz
Author by

Davuz

I love computer!

Updated on July 05, 2022

Comments

  • Davuz
    Davuz almost 2 years

    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?