MSXML “The system cannot locate the resource specified”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 01:17:30

问题


I have a function which uses MSXML to post an XML document which yesterday started failing despite no change being made to the code. The function is as follows:

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

The XML document and the address being passed in are both correct - the line which causes the error is xmlHTTP.send(xmlDoc). I have tried this on 2 different machines with the same error each time and have also tried resinstalling MSXML3, with no success.

The exception thrown is:

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"

回答1:


It turned out to be a networking issue - I didn't suspect this at first as the error was raised so quickly which didn't suggest an issue with the endpoint. The problem was with a rule which had been added (don't ask why) to the firewall preventing communication with the destination address.




回答2:


If you are just processing the xml or dtd is offline, you can use: xmlDoc.resolveExternals = False



来源:https://stackoverflow.com/questions/4041687/msxml-the-system-cannot-locate-the-resource-specified

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!