将XML发布到经典的asp页面并在页面上检索发布数据

时间:2014-04-23 17:32:10

标签: xml vbscript asp-classic serverxmlhttp

要在经典asp页面上发布数据,我使用下面的代码

Dim stringXML, httpRequest, postResponse

stringXML = "<?xml version=""1.0"" encoding=""UTF-8""?><School><Class>5</Class></School>"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
httpRequest.Open "POST", "http://www.mywebpage/TestVBScript/RecieveRequest.asp", True
httpRequest.SetRequestHeader "Content-Type", "text/xml"
httpRequest.Send stringXML

现在我想在RecieveRequest.asp页面上获取stringXML值。这样我就可以处理我的XML并发回响应

任何帮助将不胜感激。提前致谢

1 个答案:

答案 0 :(得分:2)

Dim stringXML, httpRequest, postResponse

stringXML = "<?xml version=""1.0"" encoding=""UTF-8""?><School><Class>5</Class></School>"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
httpRequest.Open "POST", "http://www.mywebpage/TestVBScript/RecieveRequest.asp", True
httpRequest.SetRequestHeader "Content-Type", "text/xml"
httpRequest.setRequestHeader "Content-Length", Len(stringXML)
httpRequest.Send stringXML

If httpRequest.status = 200 Then
    TextResponse = httpRequest.responseText
    XMLResponse = httpRequest.responseXML
    StreamResponse = httpRequest.responseStream
Else
    ' Handle missing response or other errors here
End If

Set httpRequest = Nothing