This example is very simple.
-- Park qingsong 20080811
-- The testsplit method of WS in this example is a word segmentation applet. Only test and call
Create procedure [DBO]. [pqs_testservice1]
@ C_word varchar (100), -- input string (string to be segmented)
@ C_ret varchar (200) Output -- returns a string (separated by commas (,) after word segmentation. The word segmentation code is encapsulated in WS)
As
Set nocount on
Declare @ HR int, @ object int
-- Create soapclient object
-- You need to install 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
-- Instantiate the soap Client
Exec @ hR = sp_oamethod @ object, 'mssoapinit ', null, 'HTTP: // 172.16.100.249: 911/Indexservice. asmx? WSDL'
If @ HR <> 0 -- instantiation failed
Begin
Exec sp_oageterrorinfo @ object
Return
End
-- Call the WebService method testsplit, input the parameter @ word, and return the parameter @ domain
Exec @ hR = sp_oamethod @ object, 'testsplit ', @ c_ret out, @ c_word
If @ HR <> 0 -- ws call failed
Begin
Exec sp_oageterrorinfo @ object
Return
End
Exec @ hR = sp_oadestroy @ object
If @ HR <> 0
Begin
Exec sp_oageterrorinfo @ object
Return
End
Go
-- Test
Declare @ c_ret varchar (200)
Exec [DBO]. [pqs_testservice1] 'bitdefender anti-virus settings', @ c_ret output
Select @ c_ret
-- Execution result
Bytes --------------------------------------------------------------------------------------------------
BitDefender, anti-virus security, Set
(The number of affected rows is 1)