how can I specify a proxy configuration using Microsoft.XMLHTTP?

19,635

Solution 1

I think some things here need clearing up.

The ProgID "Microsoft.XMLHTTP" points at the same class as "MSXML2.XMLHTTP". This class uses the WinINET HTTP protocol stack that Internet Explorer uses and therefore will use whatever proxy configuration is found in the Internet Settings on the PC.

Hence for "Microsoft.XMLHTTP" the proxycfg command is not useful.

An alternative to XMLHTTP is "MSXML2.ServerXMLHTTP". This class uses the WinHTTP HTTP protocol stack which is designed to be lightweight and server friendly. It is safe to use multiple instances in multiple threads in the same process where WinINET isn't. For this reason it is ServerXMLHTTP should be used in server-side ASP code.

WinHTTP does not use the Internet Settings that WinINET uses, hence to configure the proxy that ServerXMLHTTP will use you need to use the proxycfg command. A really useful command is:-

proxycfg -u

Which copies the current WinINET proxy settings to those used by WinHTTP, if you use tools like fiddler this is useful to start monitoring traffic going through WinHTTP after fiddler is started. (Note you follow up with proxycfg -d to remove the proxy settings).

ServerXMLHTTP also has a setProxy method which allows the actual proxy settings to be configured dynamically be code.

Solution 2

For windows Vista and above, the proxycfg.exe may have been deprecated, and replaced by netsh winhttp. As mentioned in this article: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384069%28v=vs.85%29.aspx

As my situation in win7, I need to do following to set proxy:

netsh winhttp set proxy myProxyServer:80

Solution 3

oops

I think I found it

http://support.microsoft.com/kb/289481/EN-US/

you have to issu something like


proxycfg -d -p myProxyServer:80 "<local>"

...

edit:

I've also found that using ServerXMLHTTP instead of XMLHttp, you have a setProxy method...

http://msdn.microsoft.com/en-us/library/ms760236(VS.85).aspx

and here is a usage example

http://msdn.microsoft.com/en-us/library/ms763680(VS.85).aspx

...

Share:
19,635
opensas
Author by

opensas

Updated on June 26, 2022

Comments

  • opensas
    opensas almost 2 years

    I'm using Microsoft.XMLHTTP from a classic asp page to post info to another site...

    I'd like to be able to inspect what's going on with fiddler, and to do so I have to find a way to configure Microsoft.XMLHTTP to use a proxy...

    is it possible? where does Microsoft.XMLHTTP gets its configuration from?

    thanks a lot