fniles said:
I need to send a request using HTTP Protocol and it will return to me some
replies, which can be an XML or HTML file. In ASP, how can I GET/POST
documents using the HTTP protocol ?
Function GetText(sURL)
Dim oXHR : Set oXHR = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXHR.open "GET", sURL, False
oXHR.send
If oXHR.status = 200 Then
GetText = oXHR.responseText
Else
GetText = Null
' Or if you prefer throw an error here
End If
End Function
This simply returns a string containing the response from the server.
You could create a similar GetXML function that an XML DOM. By changing
responseText to responseXML. It will only do so if the server responds with
a content type header indicating xml.
Function PostText(sURL, vntData, sContentType)
Dim oXHR : Set oXHR = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
oXHR.open "POST", sURL, False
If Not IsNull(sContentType) Then oXHR.setRequestHeader "ContentType",
sContentType
oXHR.send vntData
If oXHR.status = 200 Then
PostText= oXHR.responseText
Else
PostText= Null
' Or if you prefer throw an error here
End If
End Function
Again you can mod to create a PostXML version.