我有一个使用MSXML发布XML文档的函数,尽管没有对代码进行任何更改,但该文档昨天开始失败。功能如下:
Public Function PostFile(ByVal address As String, ByVal data As Byte()) As xmldocument
Dim xmlHTTP As New MSXML2.XMLHTTP
Dim response As New XmlDocument
Dim xmlDoc As New MSXML2.DOMDocument
Try
xmlDoc.load(data)
xmlHTTP.open("post", address, False)
xmlHTTP.send(xmlDoc)
If xmlHTTP.responseXML.xml <> String.Empty Then
response.LoadXml(xmlHTTP.responseXML.xml)
Return response
Else
Dim result As String = "<NO_Response><Error>the post succeeded to " + address + " but there was no responce returned</Error><Hint>Check FireWall Settings</Hint></NO_Response>"
response.loadxml(result)
Return response
End If
Catch ex As Exception
'Error logging code removed
End Try
Return Nothing
End Function
XML文档和传入的地址都是正确的 - 导致错误的行是xmlHTTP.send(xmlDoc)
。我已经在2台不同的机器上尝试了这个,每次都有相同的错误,并且尝试过树脂安装MSXML3,但没有成功。
抛出的异常是:
InnerException: Nothing
Message: "The system cannot locate the resource specified. "
Source: "msxml3.dll"
StackTrace: " at MSXML2.XMLHTTPClass.send(Object varBody) at comms.HTTPHandler.PostFile(String address, Byte[] data) in D:\SCC\Main\Sender\Http.vb:line 42"
答案 0 :(得分:10)
事实证明这是一个网络问题 - 我一开始并没有怀疑这个问题,因为错误提升得如此之快,并没有表明端点存在问题。问题在于防火墙已添加(不要问为什么)阻止与目标地址通信的规则。
答案 1 :(得分:0)
如果您只是处理xml或dtd离线,您可以使用: xmlDoc.resolveExternals = False