I wanted to send an HTTP request from SQL server to Tomcat server. I have installed SQL server 2012 express and non .NET application in Tomcat server. I have gone through this like Make a HTTP request from SQL server
As it says in the above article, "The COM object WinHttp.WinHttpRequest.5.1 must be installed on the server, some typical variations are WinHttp.WinHttpRequest.5".
I have downloaded winhttp.zip from the winhttp download link, found winhttp.dll in the zip folder and pasted it in C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVER2MSSQLBinn
as suggested in this msdn link.
Following that same advice, I have executed following line in SSMS:
sp_addextendedproc 'GetHttp',
'C:Program FilesMicrosoft SQL ServerMSSQL11.MSSQLSERVER2MSSQLBinnwinhttp.dll';
I also executed the following code in SSMS as said in "Make an HTTP request from SQL server link":
Alter function GetHttp
(
@url varchar(8000)
)
returns varchar(8000)
as
BEGIN
DECLARE @win int
DECLARE @hr int
DECLARE @text varchar(8000)
EXEC @hr=sp_OACreate 'WinHttp.WinHttpRequest.5.1',@win OUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAMethod @win, 'Open',NULL,'GET',@url,'false'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAMethod @win,'Send'
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OAGetProperty @win,'ResponseText',@text OUTPUT
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
EXEC @hr=sp_OADestroy @win
IF @hr <> 0 EXEC sp_OAGetErrorInfo @win
RETURN @text
END
Then I get the error
Msg 2010, Level 16, State 1, Procedure GetHttp, Line 2
Cannot perform alter on 'GetHttp' because it is an incompatible object type.
I do not know how to call the function to send the HTTP request. I assume it is something like this GetHttp('http://www.google.co.in/')
.
What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…