sqlserver中调用服务器中的webservice接口

declare @ServiceUrl as varchar(1000) 
declare @UrlAddress varchar(500)
--WebService地址:以http开头,结尾带斜杠,例如'http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/' 
set @UrlAddress = 'http://139.224.134.5/SGAppService/SGService.asmx/'
declare @FunName varchar(50)
--WebService中调用的方法名:例如'getMobileCodeInfo'
set @FunName = 'PushContractApproval'   
--以下参数对应WebService中4个参数的[参数名]
declare @P1 varchar(100),@P2 varchar(100)
set @P1 = 'data'
set @P2 = 'userid'
declare @P1_Value varchar(max),@P2_Value varchar(800)
set @P1_Value = '{"ServerLicenseID": "61DD8BE1-9458-41FB-AA56-DA11634E11CD"}'
set @P2_Value = ''
set @ServiceUrl = @UrlAddress + @FunName + '?' + @P1 + '=' + @P1_Value                   
Declare @Object as Int
Declare @ResponseText as Varchar(8000)
                  
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get',@ServiceUrl,'false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
     
Select @ResponseText     
Exec sp_OADestroy @Object

 

posted @ 2018-09-20 13:12  何以平天下  阅读(1671)  评论(0编辑  收藏  举报