数据库访问webservice(sqlserver 访问url)

通过SQL调用webservice
-----打开调用webservice权限
exec sp_configure 'show advanced options', 1
RECONFIGURE;
exec sp_configure 'Ole Automation Procedures', 1
RECONFIGURE;
        --訪问地址获取结果
        Declare @Object as Int
        Declare @ResponseText as nvarchar(4000) 
        Declare @ServiceUrl as nvarchar(1000) 
        DECLARE @UrlAddress nvarchar(500)
        DECLARE @FunName nvarchar(50)--WebService中调用的方法名:比如'getMobileCodeInfo'
        --以下參数相应WebService中2个參数的[參数名]
        declare @barcode  nvarchar(36)
        set @UrlAddress = 'http://mes.drive-inno.com/mes/api/chkBarcodeIsOver'
        ---SET @FunName = 'UpdateCache'   
        SET @barcode='A02000S014-C00201279'
        set @ServiceUrl=@UrlAddress+'?barcode='+ @barcode
        EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT; --创建OLE组件对象
        Exec sp_OAMethod @Object, 'open', NULL, 'post',@ServiceUrl,'false' --打开链接,注意是get还是post        
        EXEC sys.sp_OAMethod @object,'setRequestHeader',NULL,'Content-Type','application/x-www-form-urlencoded;charset=UTF-8'
        Exec sp_OAMethod @Object, 'send'
        EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT --输出參数
        Select @ResponseText      --输出结果
        Exec sp_OADestroy @Object