sqlserver 发送http请求

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

  

ALTER PROCEDURE [dbo].[Proc_System_SendSayHelloHttp]
	@Parametro varchar(10) = NULL    
AS
    DECLARE @obj INT
    DECLARE @sUrl varchar(200)
    DECLARE @response INT
    
    SET @sUrl = 'http://127.0.0.1:8008/api/Shop/SayHello'
    
    EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @obj OUT
    EXEC sp_OAMethod @obj,'Open', NULL, 'Get', @sUrl, false
    EXEC sp_OAMethod @obj,'Send'
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
    
    SELECT @response [response]
    EXEC sp_OADestroy @obj
RETURN

  

posted @ 2018-10-09 10:23  KidYang  阅读(3498)  评论(1编辑  收藏  举报