-1:利用ASP發送XMLHTTP對象:
Set xmlhttp=server.CreateObject("Msxml2.XMLHTTP")
XMLhttp.Open"POST",url,false
xmlhttp.setRequestHeader"Content-Type","text/XML;charset=utf-8"
XMLhttp.setRequestHeader"HOST","s"
XMLhttp.setRequestHeader"Content-Length",LEN(SoapRequest)
XMLhttp.setRequestHeader"SOAPAction","http://s"
XMLhttp.Send(SoapRequest)
Response.WriteXMLhttp.Status&””
Response.WriteXMLhttp.StatusText
Set XMLhttp=Nothing
獲取的時候:
If XMLhttp.Status=200 Then
Set xmlDOC=server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
xmlStr=xmlDOC.XML
SetXMLDOC=nothing
xmlStr=Replace(XMLStr,"<","<")
xmlStr=Replace(XMLStr,">",">")
Response.writeXMLStr
Else
Response.WriteXMLhttp.Status&""
Response.WriteXMLhttp.StatusText
End if
請求正確則給出完整響應,請求不正確(如賬號,密碼不對)響應的內容就會信息不完整.
取出響應裡的數據,如下:
If XMLhttp.Status=200 Then
Set xmlDOC=server.CreateObject("MSXML.DOMDocument")
xmlDOC.load(xmlhttp.responseXML)
Response.WriteXMLDOC.documentElement.selectNodes("//LoginByAccountResult")(0).text
Set XMLDOC=nothing
Else
Response.WriteXMLhttp.Status&""
Response.WriteXMLhttp.StatusText
End if