In your ASP page, when you try to load the XML document from the Request stream, if the XML document contains reference to external DTD on some different remote server, the parser tries to resolve the external reference (to the DTD), but since you have not set the ServerHTTPRequest property, it fails to load the XML document.
Alternatively, you can set the resolveExternals property to False before loading the XML document.
Let’s look at an example:
Here is a sample ASP page:
<%@ Language=VBScript %>
<%
Dim objXMLDoc
Set objXMLDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
'objXMLDoc.setProperty "ServerHTTPRequest", True
objXMLDoc.validateOnParse = False
'objXMLDoc.resolveExternals = False
If objXMLDoc.load(Request) Then
Response.Write "Top element has " & _
objXMLDoc.documentElement.attributes.length & _
" attribute(s)."
Else
Response.Write objXMLDoc.parseError.reason
End If
Set objXMLDoc = Nothing
%> The above ASP page uses MSXML 3.0 to load XML data from the request stream and if succeeds, returns the total number of attributes on the top element, else returns the parseError string.
Here is some sample Visual Basic 6.0 code that posts XML to the above ASP page. Note that the posted XML contains reference to DTD on some different remote server.
Dim objXMLHTTP As New MSXML2.XMLHTTP30
Dim xmlString As String
xmlString = "<?xml version='1.0' encoding='utf-8'?> " & vbNewLine & _
"<!DOCTYPE OrderList SYSTEM 'http://someremoteserver.com/test.dtd'>" & vbNewLine & _
"<MyDoc id='1' loc='Chicago' />"
objXMLHTTP.open "POST", "http://localhost/temp/CountAttributes.asp", False
objXMLHTTP.send xmlString
MsgBox objXMLHTTP.responseText The above Visual Basic 6.0 code uses MSXML XMLHTTP class to post some XML text to previously discussed ASP page. If you run the code as it is, you'll see the error No data is available for the requested resource.; however, if you uncomment either of the lines in the ASP page, everything should work fine.
|