Reputation: 11
I have a test form, (see below), that if I Submit manually, (clicking the Submit button), returns an XML list of orders from the action script.
I would like to be able to pass the XML currently contained in the test HTML form programmaticaly via xmlHTTP. So far no luck. Any help would be appreciated.
<form action="processorders.asp" method="post" name="Orders" target="_blank">
<textarea cols="80" rows="10" name="request">
<REQUEST Version="1.0">
<RequestID>06012005171718</RequestID>
<Command>Orders</Command>
<UserID>myuserID</UserID>
<Password>xyzuvw</Password>
<Status>all</Status>
<SecurityKey></SecurityKey>
<OrderStartNumber>2255</OrderStartNumber>
</REQUEST>
</textarea><br>
<input type="submit">
</form>
Upvotes: 1
Views: 1834
Reputation: 4374
Untested, but you could try something like this:
Dim objXMLHTTP, returncode, XMLstring
XMLstring = "<REQUEST Version=""1.0"">"
XMLstring = XMLstring & "<RequestID>06012005171718</RequestID>"
XMLstring = XMLstring & "<Command>Orders</Command>"
XMLstring = XMLstring & "<UserID>myuserID</UserID>"
XMLstring = XMLstring & "<Password>xyzuvw</Password>"
XMLstring = XMLstring & "<Status>all</Status>"
XMLstring = XMLstring & "<SecurityKey></SecurityKey>"
XMLstring = XMLstring & "<OrderStartNumber>2255</OrderStartNumber>"
XMLstring = XMLstring & "</REQUEST>"
' Create an xmlhttp object:
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Open the connection to the remote server:
objXMLHTTPOpen "POST", "http://url.to.your/target", False
objXMLHTTP.Send cstr(XMLstring)
' Actually Sends the request and returns the data:
returncode = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
' Now do with the returncode what you like (this is the response HTML form the target URL)
Please note that: - you are sending username and password data over an unsecure HTTP line - the XML is not validated or parsed, you might need to run it through an XML parser
Rico Suave
Upvotes: 1