VBA ServerXMLHTTP 代码在 Windows 7 中有效,但在 Windows 10 中失败

标签 vba windows-10 serverxmlhttp

在 Microsoft Access 中使用 VBA,我将 XML 发送到服务器以获取响应字符串。它在Windows 7中运行良好。最近,一些用户升级到Windows 10,这不再有效(Office 16上的所有用户)。具体报错是: -2147012867 - 无法建立与服务器的连接。

错误发生在xsite.send行

代码如下:

Dim xsite As ServerXMLHTTP60
Set xsite = New ServerXMLHTTP60

On Error Resume Next

xsite.setTimeouts 0, 60000, 30000, 600000

xsite.Open "POST", pServerURL & func, False
aErr = Array(Err.Number, Err.Description)
On Error GoTo 0
If 0 = aErr(0) Then 'No error creating the link
    xsite.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    'Set request header with Base64-encoded username/password
    xsite.setRequestHeader "Authorization", "Basic " & EncodeBase64(UserName & ":" & Password)
    On Error Resume Next
    xsite.send "xmlData=" & URLEncode(xmldata)
    aErr = Array(Err.Number, Err.Description)
    On Error GoTo 0

    Debug.Print aErr(0)
    Debug.Print aErr(1)
End If

有什么想法吗?

最佳答案

我遇到了类似的问题。尚未测试您的代码,但它看起来与我的相似,它也适用于 Windows7,但不适用于 Windows10。我发现是Windows10的防火墙屏蔽了。如果您关闭防火墙,您的可能会起作用。我尝试了不同的方法来对我的防火墙进行异常(exception)处理,但从未成功。因此,有几次我必须运行我的代码时,我必须关闭防火墙。

关于VBA ServerXMLHTTP 代码在 Windows 7 中有效,但在 Windows 10 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45848564/

相关文章:

Windows Server 2008 上的 Paypal 经典 asp msxml 错误

windows - WSL stash/mnt/c/Users/

c# - 激活 Windows 应用商店应用程序...失败,错误为 'The app didn' t start'

用于访问区分大小写路径的 Windows API (Bash-on-Ubuntu-on-Windows)

VBA HTTP GET 请求 - 带冒号的 cookie

json - 使用 vba 解析 JSON 时遇到问题

sql-server - MS Access/SQL Server - VBA : Upload local file to filestream on remote SQL server

vba - 从条件格式确定单元格颜色的变化

excel - VBA复制/粘贴跳过每5行