今天做了一下试验,发现当WebService返回的XML数据中使用了”Name”关键字作为健值时,ASP页面将无法读取整个XML文档,而出现以下错误:
//服务器端ASP代码如下,WebService代码略,只要返回一个DataSet的值即可
<%
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
Set xmlDOC =Server.CreateObject("MSXML.DOMDocument")
strWebserviceURL = "http://192.168.0.41/WebService1/Service1.asmx/ds"
'设置参数及其值
'strRequest = "x=2&y=3"
strRequest = "tbname=123"
objHTTP.Open "POST", strWebserviceURL, False
'设置这个Content-Type很重要
objHTTP.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.Send(strRequest)
bOK = xmlDOC.load(objHTTP.responseXML)
'看看状态值
if objHTTP.Status=200 then
xmlStr = xmlDOC.xml
xmlStr = Replace(xmlStr,"<","<",1,-1,1)
xmlStr = Replace(xmlStr,">",">",1,-1,1)
Response.Write xmlStr
else
Response.Write objHTTP.Status&"<br>"
Response.Write objHTTP.StatusText
end if
%>
'关键字Name不能用在数据库设计中!!!!!!!!!!!!
'十万个注意!!!
本文地址:http://com.8s8s.com/it/it43197.htm