Although the use of SQL Server to invoke the service interface is relatively small, but also to understand the corresponding use of the situation
First, to open the configuration of the component
sp_configure ' show advanced options ', 1; Goreconfigure; Gosp_configure ' Ole Automation procedures ', 1; Goreconfigure; goexec sp_configure ' Ole Automation procedures '; GO
Second, call WebService
1. When calling WebService, it is recommended to use Fiddler to get the type of contenttype and the data of the calling interface when sending the data.
2. Use SQL Server to invoke the corresponding interface and result
Declare @ServiceUrl as varchar set @ServiceUrl = ' Http://localhost:19930/LoginWebService.asmx/Login ' DECLARE @ Data varchar (max), set @data = ' username=8&password=7 ' Declare @Object as intDECLARE @ResponseText as varchar (+) ; Exec sp_OACreate ' msxml2.serverxmlhttp.3.0 ', @Object out; exec sp_OAMethod @Object, ' open ', null, ' POST ', @ServiceUrl, ' false ' exec sp_OAMethod @Object, ' setRequestHeader ', NULL, ' Content-type ', ' application/x-www-form-urlencoded ' exec sp_oamethod @Object, ' send ', NULL, @data--Send data Exec sp_OAMethod @Object, ' ResponseText ', @ResponseText outputexec sp_oageterrorinfo @Object--Abnormal output Select @ResponseText Exec sp_ Oadestroy @ObjectGO
Second, call Webapi, the two call the way basically the same
1. Also use Fiddler to get the interface call information (because the interface is get it does not need to see the arguments passed)
2. Interface calls and results
Get operation
Declare @ServiceUrl as varchar set @ServiceUrl = ' http://xxxxx.com/beijing/139/1000000/TaxInfo?token= 6d83d2adcff64594bd68614b6ae9e1c8 ' DECLARE @data varchar (max), set @data = ' DECLARE @Object as intDECLARE @ ResponseText as varchar (8000) ; Exec sp_OACreate ' msxml2.serverxmlhttp.3.0 ', @Object out; exec sp_OAMethod @Object, ' open ', null, ' GET ', @ServiceUrl, ' false ' exec sp_OAMethod @Object, ' send ', NULL, @data--Send data Exec sp_OAMethod @Object, ' responsetext ', @ResponseText outputexec sp_oageterrorinfo @Object--Abnormal output Select @ ResponseText Exec sp_OADestroy @ObjectGO
Post operation
Declare @ServiceUrl as varchar set @ServiceUrl = ' http://xxxx.com/Feedback/Estimate ' declare @data varchar (max);-- Send data Set @data = ' cityname=submitsystemname=%e7%99%be%e5%ba%a6%e5%8f%8d%e9%a6%88&originid= 2d90660c-436c-4e12-bfa6-e849a06b2c51&price=10000&isaccurate=false&pricetype=1&userkeyid= a669e4ec7bdc47a7b6c2c334ebe1a50c&signature=x8p3lizt0ba3leic6irm3%2fmnle8%3d&time=1452735047291 ' Declare @Object as intDECLARE @ResponseText as varchar (8000) ; Exec sp_OACreate ' msxml2.serverxmlhttp.3.0 ', @Object out; exec sp_OAMethod @Object, ' open ', null, ' POST ', @ServiceUrl, ' false ' exec sp_OAMethod @Object, ' setRequestHeader ', NULL, ' Content-type ', ' application/x-www-form-urlencoded ' exec sp_oamethod @Object, ' send ', NULL, @data--Send data Exec sp_OAMethod @Object, ' ResponseText ', @ResponseText outputexec sp_oageterrorinfo @Object--Abnormal output Select @ResponseText Exec sp_ Oadestroy @ObjectGO
SQL Server Invoke API