2010-05-06 180 views
0

我想將XML發送到同一個域上的另一個Asp Classic頁面。我使用下面的代碼發送XML如何發送和接收XML請求到另一個ASP經典頁面?

url = "http://localhost/api/xmlget.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 

,我已經設置xmlget.asp與下面的代碼接收XML:

Dim xmlDoc 
Dim userName 
set xmlDoc=Server.CreateObject("Microsoft.XMLDOM") 
xmlDoc.async="false" 
xmlDoc.load(Request) 

我運行的代碼,但沒有看到任何反映,我會怎樣知道?如果它成功,我想知道xml,我不知道從xmlDoc加載的確切屬性!

回答

0

第一:您沒有發送XML。 變量信息只有一個簡單的文本。嘗試

information = "<a>ColtTaylor100</a>" 

第二:爲什麼使用Microsoft.XMLDOM而不是MSXML2.DOMDocument? 我用它與MSXML2和工作正常。

Dim xmlDoc 
set xmlDoc=Server.CreateObject("MSXML2.DOMDocument") 
if not xmlDoc.load(Request) then 
    Response.Write xmlDoc.parseerror.reason 
    Response.End 
end if 
相關問題