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

 

SQL Server存储过程模拟HTTP请求POST和GET协议

上一篇:ARM GCC 内嵌(inline)汇编手册


下一篇:【转】UltraISO制作U盘启动盘安装Win7/9/10系统攻略