SQL Server存储过程模拟HTTP请求POST和GET协议
/****** Object: StoredProcedure [dbo].[sp_http_get] Script Date: 05/23/2020 15:47:09 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_http_get]( @URL varchar(500), @ResponseText varchar(8000) OUTPUT ) AS BEGIN Declare @Status as Int Exec sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Status OUT; Exec sp_OAMethod @Status, 'open', NULL, 'GET',@URL,'false' Exec sp_OAMethod @Status, 'send', NULL, NULL Exec sp_OAMethod @Status, 'responseText', @ResponseText OUTPUT if @Status<>0 begin EXEC sp_OAGetErrorInfo @Status end Exec sp_OADestroy @Status END GO CREATE PROCEDURE [dbo].[sp_http_post]( @URL varchar(500), @Data varchar(8000), @ResponseText varchar(8000) OUTPUT ) AS BEGIN Declare @Status as Int Exec sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Status OUT; Exec sp_OAMethod @Status, 'open', NULL, 'POST',@URL,'false' Exec sp_OAMethod @Status, 'setRequestHeader', NULL, 'Content-Type','application/x-www-form-urlencoded' Exec sp_OAMethod @Status, 'send', NULL, @Data Exec sp_OAMethod @Status, 'responseText', @ResponseText OUTPUT if @Status<>0 begin EXEC sp_OAGetErrorInfo @Status end Exec sp_OADestroy @Status END GO
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步