Sql调用WebService

DECLARE @scid int,@rt int
DECLARE @result nvarchar(4000)

--创建MSSOAP.SoapClient组件(如果安装的是SoapToolkit30,应该是MSSOAP.SoapClient30,否则是MSSOAP.SoapClient),存储到@object中
EXEC @rt=sp_OACreate 'MSSOAP.SoapClient30',@scid out

--'http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl'为webservice地址
--‘qqOnlineWebService’为webservice名称
EXEC @rt = sp_OAMethod @scid, 'mssoapinit',null,'http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl','qqOnlineWebService'

--'qqCheckOnline'为webservice的一个方法,后面跟2个参数(输入参数:QQ号码 String,默认QQ号码:8698053。返回数据:String,Y = 在线;N = 离线;E = QQ号码错误;A = 商业用户验证失败;V = 免费用户超过数量)
EXEC @rt = sp_OAMethod @scid, 'qqCheckOnline', @result OUT,N'8698053'

IF @rt <> 0
BEGIN
   EXEC sp_OAGetErrorInfo @scid   
END
ELSE
BEGIN
   select @result
END
--释放掉@scid
EXEC @rt = sp_OADestroy @scid
GO

 

posted @ 2014-01-21 16:37  fang_beny  阅读(2699)  评论(0编辑  收藏  举报