zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    protobuf 中的嵌套消息的使用
    Mysql++详解
    MYSQL++之Connect类型
    c/c++中宏定义##连接符 和#符的使用
    c指针
    linux学习历程
    linux sar 命令详解
    Linux下多线程查看工具(pstree、ps、pstack)
    知识杂项
    python 使用xrld
  • 原文地址:https://www.cnblogs.com/icyhoo/p/12942833.html
Copyright © 2011-2022 走看看