Instance of calling WebService in SQL Server

Source: Internet
Author: User
Tags ole

Respect the original works: reproduced in this article from http://www.cnblogs.com/icycore/p/3532197.html

1.Ole Automation Procedures Server configuration options

When OLE Automation procedures is enabled, calls to sp_OACreate will start the OLE shared execution environment.

Ole Automation Procedures option can be viewed and changed by using the sp_configure system stored proced Ure. "Data-guid=" 39a0a531b1194eeda90b9f2140b44647 "can use   sp_ Configure   system stored procedures to view and change ole Automation procedures  option.

' Show advanced Options ' 1  'Ole Automation procedures'1; Goreconfigure; GO
View Code

2. Write the SQL code and execute

DECLARE @ServiceUrl asvarchar +) declare @UrlAddress varchar ( -)--webservice address: Starts with HTTP and ends with a slash, for example'http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/' Set@UrlAddress ='http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/'declare @FunName varchar ( -)Method name called in--webservice: for example'Getmobilecodeinfo'Set@FunName ='Getmobilecodeinfo'--The following parameters correspond to the parameter names of the 4 parameters in WebService]declare @P1 varchar ( -), @P2 varchar ( -)Set@P1 ='Mobilecode'Set@P2 ='userid'declare @P1_Value varchar ( -), @P2_Value varchar ( -)Set@P1_Value ='13800138000'Set@P2_Value ="'Set@ServiceUrl = @UrlAddress + @FunName +'?'+ @P1 +'='+ @P1_Value +'&'+ @P2 +'='+@P2_Value Declare @Object asintDECLARE @ResponseText asVarchar (8000) Exec sp_OACreate'msxml2.xmlhttp', @Object out; Exec sp_OAMethod @Object,'Open'Null'Get', @ServiceUrl,'false'Exec sp_OAMethod @Object,'Send'Exec sp_OAMethod @Object,'ResponseText', @ResponseText OUTPUT Select @ResponseText Exec sp_OADestroy @ObjectGO
View Code

Be aware that the returned result is an XML encoding with parsing.

Instance of calling WebService in SQL Server

Related Article

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.