SQL Call WebService Interface

Source: Internet
Author: User



Today is doing a very wonderful thing, in the middle of a process to call the WebService interface in the SQL trigger. hehe ~


--Call WebService----------------declare @ServiceUrl as varchar declare @UrlAddress varchar (500)-- WebService address: Start with HTTP, end with Slash, for example ' http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/' Set @UrlAddress = ' http://api.map.baidu.com/telematics/v3/weather?location=%E5%8C%97%E4%BA%AC&output=json&ak= 6brzizyakotew1xrdyk0wqhd ' SET @[email protected] If an argument can be entered here--access address get results declare @Object as intDECLARE @ResponseText as Varchar (8000)--Must 8000                  EXEC sp_OACreate ' MSXML2. XMLHTTP ', @Object out; --Create OLE Component Object exec sp_OAMethod @Object, ' open ', NULL, ' POST ', @ServiceUrl, ' false '--open the link, note whether it is get or postexec sp_OAMethod @ Object, ' send ' EXEC sp_oamethod @Object, ' responsetext ', @ResponseText output-parameter     Select @ResponseText      -- Output result exec sp_OADestroy @ObjectGO


Here webservice is just a test interface provided by Baidu, the real use of the time, we can write their own interface, and then invoke their own written interface, remote execution method.









Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

SQL Call WebService Interface

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.