SQL server2k WebService Solution

Source: Internet
Author: User
Tags soap client

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)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.