该示例很简单,不多说了。
--朴青松 20080811
--需要安装 SOAP Toolkit 3.0
--下载地址:http://download.microsoft.com/download/2/e/0/2e068a11-9ef7-45f5-820f-89573d7c4939/soapsdk.exe
exec @hr = sp_OACreate 'MSSOAP.SoapClient30', @object out
--实例化 SOAP Client
exec @hr=sp_OAMethod @object, 'MSSoapInit',null, 'http://172.16.100.249:911/IndexService.asmx?wsdl'
if @hr <> 0 --实例化失败
begin
exec sp_OAGetErrorInfo @object
return
end
--调用WebService方法 TestSplit,输入参数 @Word,返回参数 @domain
exec @hr= sp_OAMethod @object, 'TestSplit', @c_Ret out,@c_Word
begin
exec sp_OAGetErrorInfo @object
return
end
exec [dbo].[Pqs_TestService1] 'bitdefender杀毒安全套装',@c_ret output
--------------------------------------------------------------------------------------------------
bitdefender,杀毒安全,套装
(所影响的行数为 1 行)
--这里面的WS的TestSplit方法是一个分词小程序,这里仅测试调用
Create PROCEDURE [dbo].[Pqs_TestService1]@c_Word varchar(100), --输入字符串(要分词的字符串)
@c_Ret varchar(200) output --返回字符串(分词后字符串,用逗号分隔,分词代码封装在WS中)
as
set nocount on
declare @hr int,@object int
--创建 Create SOAPClient对象--需要安装 SOAP Toolkit 3.0
--下载地址:http://download.microsoft.com/download/2/e/0/2e068a11-9ef7-45f5-820f-89573d7c4939/soapsdk.exe
exec @hr = sp_OACreate 'MSSOAP.SoapClient30', @object out
--实例化 SOAP Client
exec @hr=sp_OAMethod @object, 'MSSoapInit',null, 'http://172.16.100.249:911/IndexService.asmx?wsdl'
if @hr <> 0 --实例化失败
begin
exec sp_OAGetErrorInfo @object
return
end
--调用WebService方法 TestSplit,输入参数 @Word,返回参数 @domain
exec @hr= sp_OAMethod @object, 'TestSplit', @c_Ret out,@c_Word
if @hr <> 0 --调用WS失败
begin
exec sp_OAGetErrorInfo @object
return
end
exec @hr = sp_OADestroy @object
if @hr <> 0begin
exec sp_OAGetErrorInfo @object
return
end
GO
--测试
exec [dbo].[Pqs_TestService1] 'bitdefender杀毒安全套装',@c_ret output
select @c_ret
--执行结果--------------------------------------------------------------------------------------------------
bitdefender,杀毒安全,套装
(所影响的行数为 1 行)