sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
declare @ServiceUrl as varchar(1000)
declare @UrlAddress varchar(500) --WebService地址:以http开头,结尾带斜杠,例如'http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/'
set @UrlAddress = 'http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=13666666666&userID=' declare @FunName varchar(50)
--WebService中调用的方法名:例如'getMobileCodeInfo'
set @FunName = 'getMobileCodeInfo' --以下参数对应WebService中4个参数的[参数名]
declare @P1 varchar(800),@P2 varchar(100)
set @P1 = 'mobileCode'
set @P2 = 'userid' declare @P1_Value varchar(100),@P2_Value varchar(100)
set @P1_Value = ''
set @P2_Value = '' set @ServiceUrl = @UrlAddress + @FunName + '?' + @P1 + '=' + @P1_Value +'&' + @P2 + '=' + @P2_Value Declare @Object as Int
Declare @ResponseText as Varchar(8000) Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get',@UrlAddress,'false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT Select @ResponseText
Exec sp_OADestroy @Object
GO
成功之后会返回一个XML文件
引自:http://www.cnblogs.com/icycore/p/3532197.html