What do the iNet control, XMLHTTP and web services have in common? They all use HTTP tunneling. In this 3 part series, Adnan gets under the hood and shows us exactly what HTTP tunneling is.
HTTP Tunneling Revealed: Part 1/3 - A ServerXMLHTTP Example (Page 5 of 6 )
<%@ Page aspcompat=true %> <% Dim objXMLHTTP, xml, flightnumber, url '//Reading flight number from query string flightnumber=request("flightnumber")
' Create an Server xmlhttp object: xml = Server.CreateObject("MSXML2.ServerXMLHTTP") url = "http://shop.baa.co.uk/cgi-bin/ncommerce3/ExecMacro/flights/arrivals.d2w/report ?flightnumber="&cstr(flightnumber)&"&comingfrom=& hour=Hour&min=Min& hourselect=0&minselect=0& airport=LHR&timeframe=& terminalselect=0&terminal=All" ' Opens the connection to the remote server. xml.Open ("GET", url, False)
' Actually Sends the request and returns the data: xml.Send Response.Write ("<h1>This is generated results from BAA using Server XMLHTTP </h1>") Response.Write (xml.responseText) xml = Nothing %>
Handling POST requests using ServerXMLHTTP It's quite simple to do POST requests to remote web sites. I demonstrate below how to query www.imdb.com (Internet Movie Database) for "My big fat Greek wedding", one of the most hilarious comedies of the year:
<%@ Page aspcompat=true Debug="true"%> <% Dim objXMLHTTP, xml, flightnumber, url ' Create an Server xmlhttp object: xml = Server.CreateObject("MSXML2.ServerXMLHTTP") url = cstr("http://www.imdb.com/Find") xml.Open ("POST", url , False) xml.Send ("select=All&for=My big fat Greek wedding") Response.Write ("<h1>This is generated results from IMDB using Server XMLHTTP </h1>") Response.Write (xml.responseText) xml = Nothing %>
This is almost the same as get, however the Open method argument was replaced with POST, and the send method now includes POST data.
The syntax for data via post is the same as a query string, but the question mark "?" used to signify the start of the URL query string is now eliminated.