Post XML to classic asp page and retrieve the post

2019-03-05 13:51发布

问题:

To post data on classic asp page i am using below code

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

Now I want to get the stringXML value on RecieveRequest.asp page. So that i can process my XML and send back the response

Any help will be appreciated. Thanks in advance

回答1:

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