我试图将HTTP get发送到内部网络服务器,这样可以正常工作,除非由于重新路由原因,用户必须遍历代理才能访问网络服务器,然后我才会获得WinInet 12029错误" ERROR_INTERNET_CANNOT_CONNECT尝试连接服务器失败。"请问您可以帮我拉入现有的Internet Options代理配置吗?我不想静态定义代理凭据(我也没试过)。
我的代码:
Function HTTPGet1
Dim o, URL, stat
URL = myURL
On Error Resume Next
Set o = CreateObject("Microsoft.XMLHTTP")
' If Err.Number <> 0 Then
'msgbox err.Number & err.Description
'msgbox "cake"
'Exit Function
' End if
o.WinHttpGetIEProxyConfigForCurrentUser
o.open "GET", URL, False
o.send
stat = o.Status 'CInt(o.Status)
if stat = "200" then
msgbox "Account created successfully."
elseif stat = "" then
msgbox "Connection attempt failed due to: " & err.description & "."
err.clear
else
msgbox "HTTP error code " & stat & " received."
end if
end function
谢谢你的时间!
答案 0 :(得分:1)
使用最新版本的ServerXMLHTTP对象
Set xHttp= CreateObject("MSXML2.ServerXMLHTTP.6.0")
xHttp.Open "POST", SERVER_URL, data, False
xHttp.setProxy 2, "<Your proxy URL>:<PORT>", ""
xHttp.send
response = xHttp.responseText
msgbox xHttp.status & "|" & xHttp.statustext
msgbox "Response for get call is :" & response
答案 1 :(得分:0)
pcap发现服务器正在响应此API无法响应的SSL证书错误。我将它换成MSXML2.ServerXMLHTTP.6.0然后能够处理主机名不匹配。
Function HTTPGet1
Dim o, address, caseNo, URL, stat
URL = myURL
On Error Resume Next
Set o = CreateObject("MSXML2.ServerXMLHTTP.6.0")
If Err.Number <> 0 Then
msgbox err.Number & err.Description
err.clear
Exit Function
End if
o.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
o.open "GET", URL, False
o.send
stat = o.Status
参数'SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS'只是通过API提供的选项之一,而且这个选项不是最安全的。