Discussion:
Looking for an HTTP Object that works like WinHTTP.WinHTTPRequest.5.1
(too old to reply)
Travis McGee
2008-07-10 21:07:29 UTC
Permalink
I need to create this functionality outside of the IIS with an object - pre
.NET code.
The code below is part of a classic ASP.

<%
Set objHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
objHttp.open "POST", www.Microsoft.com/myPage.asp, False
WinHttpRequestOption_SslErrorIgnoreFlags = 4
objHttp.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300
objHttp.Send "firstName=Dick&lastName=Cheney&status=GodKnows"
sReturnedResponse = objHttp.responseText
%>

So you just cannot do an OLE call ==>
CreateObject("WinHTTP.WinHTTPRequest.5.1") , becuase this object is part of
the IIS server and is isolated, I think.

Does anybody know an Object that is part of the Win 2003 or 2008 (already
installed) but can be called with CreateObject("xxxxx").

Example: MSXML does not work, because you cannot POST the Named pairs
seperately, it has to be part of the URL. And perhaps there is no way of
setting flags like the SslErrorIgnoreFlag
Set XMLHTTP = CreateObject("Msxml2.XMLHTTP")
XMLHTTP.Open "POST", sUrl & "?" & sPairs, False
x = XMLHTTP.send()

Anything will help
Old Pedant
2008-07-10 22:24:16 UTC
Permalink
Just using MSXML2 wrong.
<%
Set objHttp = Server.CreateObject("msxml2.ServerXMLHTTP")
objHttp.open "POST", "www.Microsoft.com/myPage.asp", False
objHttp.Send "firstName=Dick&lastName=Cheney&status=GodKnows"
sReturnedResponse = objHttp.responseText
%>

Caution: Some servers won't accept the POST from non-browser requestors.
(Ran into that a while back.)
Old Pedant
2008-07-10 22:34:00 UTC
Permalink
Ugh...just tried my answer on a couple of different sites with no luck.

But others have done this quite successfully. Just answered a post the
other day where a guy did this to hit a credit card processing site.

Double ugh.
Old Pedant
2008-07-10 22:55:04 UTC
Permalink
Got it!

Forgot about needing to set the Content-Type header value.

Here, you can try it:

Set http = CreateObject("msxml2.ServerXMLHTTP")
http.Open "POST", "http://www.clearviewdesign.com/silly.asp", False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.Send "id=7&name=barney"
WScript.Echo "Received: " & http.ResponseText
Anthony Jones
2008-07-11 07:35:49 UTC
Permalink
Post by Travis McGee
I need to create this functionality outside of the IIS with an object - pre
.NET code.
The code below is part of a classic ASP.
<%
Set objHttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1")
objHttp.open "POST", www.Microsoft.com/myPage.asp, False
WinHttpRequestOption_SslErrorIgnoreFlags = 4
objHttp.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300
objHttp.Send "firstName=Dick&lastName=Cheney&status=GodKnows"
sReturnedResponse = objHttp.responseText
%>
So you just cannot do an OLE call ==>
CreateObject("WinHTTP.WinHTTPRequest.5.1") , becuase this object is part of
the IIS server and is isolated, I think.
WinHTTP is pretty ubiquitous these days and is available on all windows
platforms in current support.
Post by Travis McGee
Does anybody know an Object that is part of the Win 2003 or 2008 (already
installed) but can be called with CreateObject("xxxxx").
Example: MSXML does not work, because you cannot POST the Named pairs
seperately, it has to be part of the URL. And perhaps there is no way of
setting flags like the SslErrorIgnoreFlag
Set XMLHTTP = CreateObject("Msxml2.XMLHTTP")
XMLHTTP.Open "POST", sUrl & "?" & sPairs, False
x = XMLHTTP.send()
Anything will help
I'm not sure understand your comment about named pairs, its quite common to
use XMLHTTP to emulate a standard HTML Form post which use this sort of
pairing.

However since you need to fiddle with some other request options you can use
WinHTTP. You'll have a problem if the clients are Win95/98 though.
--
Anthony Jones - MVP ASP/ASP.NET
Old Pedant
2008-07-11 18:53:03 UTC
Permalink
Post by Anthony Jones
I'm not sure understand your comment about named pairs,
I think he simply made the same omission I did. Forgot to add the
Content-Type header:
http.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"

If you forget that, then indeed the POST does *NOT* work (at least not in
ASP pages). Request.Form is seen as NULL.

So his "named pairs" was just referring to the POST contents, nothing more.
Loading...