简体   繁体   中英

how to Call web service using stored procedure which returns json and store data in table using sql server?

how to Call web service using stored procedure which returns json and store data in table using sql server?

  ==============
  Declare @Object as Int;
  Declare @ResponseText as Varchar(8000);

--Code Snippet
 Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
 Exec sp_OAMethod @Object, 'open', NULL, 'get',
             'WEB SERVICE LINK', --Your Web Service Url (invoked)
             'false'
 Exec sp_OAMethod @Object, 'send'
 Exec sp_OAGetProperty@Object, 'responseText', @ResponseText OUTPUT

 Select @ResponseText

 Exec sp_OADestroy @Object
DECLARE @Object AS INT ;
            DECLARE @ResponseText AS VARCHAR(8000) ;
            DECLARE @Url AS VARCHAR(1000) ;
            SET @Url = 'Web service'

            EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT ; --
            EXEC sp_OAMethod @Object, 'open', NULL, 'get', @Url,'false'           
            EXEC sp_OAMethod @Object, 'send'
            EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

            SELECT  @ResponseText

            EXEC sp_OADestroy @Object

            DECLARE @handle INT 
            DECLARE @PrepareXmlStatus INT  


            EXEC @PrepareXmlStatus= sp_xml_preparedocument @handle OUTPUT,
                @ResponseText

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM