I am writing both sides of an ASP-webpage to ASP-webpage conversation in which the originating webpage pushes information to the receiving webpage which then processes it and sends back a response. The originating webpage must use the code below to start the converstation:
url = "www.receivingwebsite.com\asp\receivingwebpage.asp
information = "UserName=Colt&PassWord=Taylor&Data=100"
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send information
...and then somehow the ASP code in the receiving page has to be able to see the information that was sent. I have tried everything I can think of. The information is not in the request object's querystring
or form arrays (because the content-type is text/xml
) and I've tried passing the entire request object to a domdocument
via its load()
and/or loadxml()
methods.
No matter what I do, I can't find the information but I know that it is being sent because when I change the content-type to application/x-www-form-urlencoded
, I can see it in request.form
array.
So where is my information when the content-type is text/xml
?
When you set the content-type to "text/xml" you really need to send the information as an XML string, not a name-value list.
url = "www.receivingwebsite.com\asp\receivingwebpage.asp"
information = "<Send><UserName>Colt</UserName><PassWord>Taylor</PassWord><Data>100</Data></Send>"
Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send information
Then, in your receiving ASP page, you would then capture the XML as follows:
Dim xmlDoc
Dim userName
set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(Request)
userName = xmlDoc.documentElement.selectSingleNode("UserName").firstChild.nodeValue
来源:https://stackoverflow.com/questions/369226/receiving-xml-from-another-websites-call-to-serverxmlhttp-post-in-classic-asp