zoukankan      html  css  js  c++  java
  • sqlserver调用webapi

    1.开启组件(2012以上版本支持)

    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

    2.调用api

    declare @ServiceUrl as varchar(1000) 
    set @ServiceUrl = 'http://localhost:52261/Api/Values'
    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, 'GET',@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

    返回结果:

     

  • 相关阅读:
    测试之美-1
    杯子测试
    性能面试(四)
    性能面试(二)
    性能面试(三)
    性能面试(一)
    解决用户名冲突
    版本冲突
    JQuery Easy UI 简介
    Fork
  • 原文地址:https://www.cnblogs.com/Linky008/p/11129416.html
Copyright © 2011-2022 走看看