使用 MSXML2.XMLHTTP 或 MSXML2.ServerXMLHTTP 發送 HTTPS POST 請求至微信統一下單 API,返回 msxml3.dll 錯誤 '800c0008' 指定資源下載失敗。
MSXML2.XMLHTTP 依賴 WinHTTP 5.1,舊版不支援現代加密套件Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000A80 ; TLS 1.0 | TLS 1.1 | TLS 1.2
WinHttp.WinHttpRequest.5.1 物件:Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
http.SetAutoLogonPolicy 0
http.Open "POST", "https://api.mch.weixin.qq.com/pay/unifiedorder", False
http.SetRequestHeader "Content-Type", "application/xml; charset=utf-8"
http.SetRequestHeader "Accept", "application/xml"
http.Send strxml
Response.Write http.ResponseText
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
http.SetOption 2, 13056 ' SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
http.Open "POST", "https://api.mch.weixin.qq.com/pay/unifiedorder", False
http.SetRequestHeader "Content-Type", "application/xml; charset=utf-8"
http.Send strxml
Server.CreateObject("MyComComponent.HttpHelper") 呼叫Function BuildWeChatXml(params)
Dim xml: xml = ""
For Each key In params
xml = xml & "<" & key & ">" & EscapeXML(params(key)) & "" & key & ">"
Next
xml = xml & " "
BuildWeChatXml = xml
End Function
Function EscapeXML(str)
str = Replace(str, "&", "&")
str = Replace(str, "<", "<")
str = Replace(str, ">", ">")
EscapeXML = str
End Function
| 項目 | 檢查點 |
|---|---|
| 伺服器 OS | Windows Server 2008 R2 SP1 以上 |
| 補丁 | 已安裝 KB3140245 |
| 登錄 | DefaultSecureProtocols = 0xA80 |
| 物件 | 使用 WinHttp.WinHttpRequest.5.1 |
| 憑證 | 微信根憑證已匯入 Trusted Root CA |
建議逐步遷移至 ASP.NET Core 或其他現代框架,徹底解決舊技術棧的安全與相容性問題。