8

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"
bluish
  • 26,356
  • 27
  • 122
  • 180
Macros
  • 7,099
  • 2
  • 39
  • 61
  • See my solution here: https://stackoverflow.com/questions/46247627/excel-vba-send-to-msxml2-xmlhttp-does-not-work/59792203#59792203 – David Najman Jan 17 '20 at 17:41

2 Answers2

15

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.

Macros
  • 7,099
  • 2
  • 39
  • 61
  • 3
    up! just cause it saved me unnecessary debugging – idanshmu Jan 07 '15 at 16:23
  • Thanks for leading me in the right direction. The error message initially made me think I was going to have to trouble shoot the permissions to the COMS object itself. But, the error just meant the xmlhttp object wasn't able to connect to the url successfully. – AdamantineWolverine Aug 24 '15 at 16:13
  • We just had a server go down. Another server was attempting to make an XMLHTTP request to that server and we got this same msxml3.dll error. I wouldn't have put 2 and 2 together based on the error message, seemed more like a local server issue with the DLL than the DLL unable to find the server it was looking for. Good to know. – Gary Richter Jul 13 '17 at 18:04
  • You're right the exception is raised instantly which was leading me in the wrong direction, but the issue was a proxy server setting and the application was no longer able to reach the target. – Jacob M. May 05 '21 at 01:33
  • I am trying to fix this same problem with my domain provider but they claim no rule i blocking the address. where should i point them to? also, we are still able to receive requests from that address on our webhook page. is it possible it's only blocked one way? – Noam Smadja Sep 22 '22 at 13:37
0

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