Thursday, March 8, 2012

Call webservice from trigger/stored proc

Is it possible to call an external web service from a SQL Server trigger or stored procedure?You can sort of call a web service from a stored procedure, but it takes a lot of bubble gum and bailing wire to make it work. Can you describe what you want in a bit more detail, and one of us might have an idea or three that might help.

-PatP|||Hi
I want to call the web services which is developed in .net from sqlserver 2000.So please do help me.|||Here is a sample code (without error handling):

declare @.objRef int
,@.resultcode int
,@.responseText varchar(8000)

EXEC @.resultcode = sp_OACreate 'MSXML2.ServerXMLHTTP', @.objRef OUT,4
EXEC @.resultcode = sp_OAMethod @.objRef, 'Open', NULL,'GET','http://myurl.com', False
EXEC @.resultcode = sp_OAMethod @.objRef, 'Send',null
EXEC @.resultcode = sp_OAGetProperty @.objRef, 'responseText',@.responseText output

print(@.response)

EXEC sp_OADestroy @.objRef

No comments:

Post a Comment