Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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

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

...

I looked at this thread to solve my issue - it helped but there are changes to newer systems now.
My situation was making a web MSXML2.ServerXMLHTTP Call from a corporate server going through Proxy Server with digested Active Directory Credentials.

There were a couple issues here for me, but I eventually managed to get it to work with just the Standard MSXML2.ServerXMLHTTP without having to specify the .3.0 or .6.0 versions.

Newer windows servers do not have proxycfg, you need to use netsh as mentioned earlier.

There are a few things you need lined up.
In my scenario I was running the Website and Application Pool under the credentials of the AD User Account (This was required for database access) I would suggest that at least the Application Pool would need to run as the AD Account

This was on a 64 Bit Windows System

  1. Obviously the AD User will need to have internet access
  2. You will need to specify the winhttp proxy settings using netsh
  3. If you have 'Enable 32 bit Applications' Enabled you will also need to set the winhttp proxy for 32 bit. It will look for that setting.

So how?

Check winhttp proxy settings At the Command Line

%WINDIR%\System32\NETSH WINHTTP SHOW PROXY

Check winhttp proxy settings At the Command Line

%WINDIR%\SysWOW64\NETSH WINHTTP SHOW PROXY

If you need to set them From the Command Line [change 8080 to your port]

%WINDIR%\System32\NETSH WINHTTP SET PROXY PROXYSERVERURL:8080
%WINDIR%\SysWOW64\NETSH WINHTTP SET PROXY PROXYSERVERURL:8080
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top