--sql 服務器設置
--啟動 OLE Automation Procedures
sp_configure 'show advanced options', 1; --此選項用來顯示sp_configure系統存儲過程高級選項,當其值為1時,可以使用sp_configure列出高級選項。默認為0;
GO
RECONFIGURE WITH OVERRIDE;
GO
sp_configure 'Ole Automation Procedures', 1; --此選項可指定是否可以在Transact-SQL批處理中實例化OLEAutomation 對象。
GO
RECONFIGURE WITH OVERRIDE;
GO
EXEC sp_configure 'Ole Automation Procedures'; --查看OLE Automation Procedures的當前設置。
GO
--存儲過程調用示例
declare @ServiceUrl as varchar(1000)
set @ServiceUrl = 'http://172.17.1.214:10005/clmsApi/thirdInterfaceDel/insertDatas'
DECLARE @data varchar(max);
--發送數據
set @data='{
"evtcode": "BD_DOC_04.SC0001.EV_DOC004",
"input": { "jk_type":1,
"jzlb":2,
"details": '+@jsonDatas+'
}
}
'
Declare @Object as Int
Declare @ResponseText AS varchar(8000) ;
select 1;
Exec sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Object OUT;
select 2;
Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false'
select 3;
Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','application/json'
select 4;
Exec sp_OAMethod @Object, 'send', NULL, @data --發送數據
select 5;
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
EXEC sp_OAGetErrorInfo @Object --異常輸出
Select @ResponseText
Exec sp_OADestroy @Object