View Single Post
  #5 (permalink)  
Old March 29th, 2006, 07:42 AM
Papak Papak is offline
Registered User
 
Join Date: Mar 2006
Location: Kolkata, West Bengal, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Papak
Default

Http Post can be done from Sql Server 2000 with Stored Procedure. I have done and implemented it .

Here is the Stored Procedure :


CREATE procedure HTTP_POST( @sUrl varchar(200), @response varchar(8000)
out)
As


Declare
@obj int
,@hr int
,@status int
,@msg varchar(255)


exec @hr = sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
-- exec @hr = sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
if @hr <> 0 begin Raiserror('sp_OACreate MSXML2.ServerXMLHttp.3.0
failed', 16,1) return end


exec @hr = sp_OAMethod @obj, 'open', NULL, 'POST', @sUrl, false
if @hr <>0 begin set @msg = 'sp_OAMethod Open failed' goto eh end


exec @hr = sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type',
'application/x-www-form-urlencoded'
if @hr <>0 begin set @msg = 'sp_OAMethod setRequestHeader failed' goto
eh end


exec @hr = sp_OAMethod @obj, send, NULL, ''
if @hr <>0 begin set @msg = 'sp_OAMethod Send failed' goto eh end


exec @hr = sp_OAGetProperty @obj, 'status', @status OUT
if @hr <>0 begin set @msg = 'sp_OAMethod read status failed' goto
eh
end


if @status <> 200 begin set @msg = 'sp_OAMethod http status ' +
str(@status) goto eh end


exec @hr = sp_OAGetProperty @obj, 'responseText', @response OUT
if @hr <>0 begin set @msg = 'sp_OAMethod read response failed' goto
eh end


exec @hr = sp_OADestroy @obj
return
eh:
exec @hr = sp_OADestroy @obj
Raiserror(@msg, 16, 1)
return
GO


I think it will he helpful to you.

Thanks
Papak


Papak Mondal
Senior Developer
http://www.autocastle.com
Reply With Quote