我們無法通過SQL Server 2000上的存儲過程發送http文章。SQL是我們必須發送http文章的唯一方法。Http post SQL Server 2000存儲過程
我們顯然沒有發送[fin,ack],並且連接不夠快速關閉。誰能告訴我問題是什麼?
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_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
return
GO
我調用存儲過程像這樣
exec HTTP_POST 'http://123.123.123.123/example.webservice?time=201205021000000'
你可以在SQL之外測試(而不是生產)嗎?如果是這樣,如果從VB腳本運行,你會得到相同的問題?你能執行一個xp_cmdshell並運行一個腳本嗎? –
這可能是一個選項,雖然是否可以通過使用此存儲過程強制關閉連接?我想如果連接被強制關閉,這可能會解決我的問題 – Imsopov
我不後悔。我只是提供一種方法來首先找出問題。 –