码迷,mamicode.com
首页 > 数据库 > 详细

sql调接口

时间:2018-11-24 17:58:51      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:taf   tde   use   als   data   user   proc   form   open   

--开启Sql Server 通讯配置--
sp_configure ‘show advanced options‘, 1;
GO
RECONFIGURE;
GO
sp_configure ‘Ole Automation Procedures‘, 1;
GO
RECONFIGURE;
GO
EXEC sp_configure ‘Ole Automation Procedures‘;
GO

--GET
declare @ServiceUrl as varchar(1000)
--set @ServiceUrl = ‘http://api.data.rx/api/rs/getdeptstaffstat?city=18&region=0‘
set @ServiceUrl = ‘http://edu.rx/a/api/getQuesUserNum?region=11&startTime=2018-8-8&endTime=2018-8-25‘
DECLARE @data varchar(max);
set @data=‘‘

Declare @Object as Int
Declare @ResponseText AS VARCHAR(8000);
Exec sp_OACreate ‘Msxml2.ServerXMLHTTP.3.0‘, @Object OUT;
Exec sp_OAMethod @Object, ‘open‘, NULL, ‘post‘,@ServiceUrl,‘false‘
Exec sp_OAMethod @Object, ‘send‘, NULL, @data --发送数据
Exec sp_OAMethod @Object, ‘responseText‘, @ResponseText OUTPUT
EXEC sp_OAGetErrorInfo @Object --异常输出
Select @ResponseText
Exec sp_OADestroy @Object
GO

--post
declare @ServiceUrl as varchar(1000)
set @ServiceUrl = ‘http://edu.rx/a/api/getQuesUserNum‘
DECLARE @data varchar(max);
--发送数据
set @data=‘region=11&startTime=2018-8-8&endTime=2018-8-25‘

Declare @Object as Int
Declare @ResponseText AS varchar(8000) ;
Exec sp_OACreate ‘Msxml2.ServerXMLHTTP.3.0‘, @Object OUT;
Exec sp_OAMethod @Object, ‘open‘, NULL, ‘POST‘,@ServiceUrl,‘false‘
Exec sp_OAMethod @Object, ‘setRequestHeader‘, NULL, ‘Content-Type‘,‘application/x-www-form-urlencoded‘
Exec sp_OAMethod @Object, ‘send‘, NULL, @data --发送数据
Exec sp_OAMethod @Object, ‘responseText‘, @ResponseText OUTPUT
EXEC sp_OAGetErrorInfo @Object --异常输出
Select @ResponseText
Exec sp_OADestroy @Object
GO

sql调接口

标签:taf   tde   use   als   data   user   proc   form   open   

原文地址:https://www.cnblogs.com/Mzg121584668/p/10012771.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!