I am attempting to create a WinHTTPRequest object in which I have to send some information to the server before I post some xml data to a service that is running on the server.
The code Compiles just fine however when I run it gives the error Cannot Create Automation Object on the following line
Set oWinHttpReq = CreateObject ( “WinHttp.WinHttpRequest”)
Here is the ret of the code …
Public Function InvokeWebService(Byval sURL As String, _
Byval sUserID As String, _
Byval sPassword As String, _
Byval bUsePost As Boolean, _
Byval sPostElements As Variant)
'On Error Resume Next
Const wcMethodName = "InvokeWebService"
Dim oWinHttpReq
Dim lTimeOut As Long
Dim iCount As Long
Dim iLogonCount As Integer
Dim sResponse As String
Dim m_sResponse
Dim bByteResponse() As Byte
Set oWinHttpReq = CreateObject ( "WinHttp.WinHttpRequest")
iLogonCount = 0
lTimeOut = wcWebServiceTimeout
retryWebService:
If bUsePost Then
oWinHttpReq.Open "POST", _
sURL, False
oWinHttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
Call oWinHttpReq.SetCredentials(sUserID, sPassword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER)
oWinHttpReq.SetTimeouts lTimeOut, lTimeOut, lTimeOut, lTimeOut
oWinHttpReq.Send sPostElements
Else
oWinHttpReq.Open "GET", _
sURL, False
Call oWinHttpReq.SetCredentials(sUserID, sPassword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER)
oWinHttpReq.SetTimeouts lTimeOut, lTimeOut, lTimeOut, lTimeOut
oWinHttpReq.Send
End If