Old Method :
DECLARE @URI varchar(8000),
@output_XML varchar(8000),
@result int,
@object int
set @URI = 'http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=MSFT'
EXEC @result = sp_OACreate 'MSXML2.ServerXMLHTTP.6.0', @object OUTPUT
IF @result <> 0
BEGIN
RAISERROR('sp_OACreate on MSXML2.XMLHttp.6.0 failed', 16,1)
RETURN
END
EXEC @result = sp_OAMethod @object, 'open', NULL, 'GET', @URI, false
IF @result <>0
BEGIN
RAISERROR('sp_OAMethod Open failed', 16,1)
RETURN
END
EXEC @result = sp_OAMethod @object, SEND, NULL, ''
IF @result <>0
BEGIN
RAISERROR('sp_OAMethod SEND failed', 16,1)
RETURN
END
@output_XML varchar(8000),
@result int,
@object int
set @URI = 'http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=MSFT'
EXEC @result = sp_OACreate 'MSXML2.ServerXMLHTTP.6.0', @object OUTPUT
IF @result <> 0
BEGIN
RAISERROR('sp_OACreate on MSXML2.XMLHttp.6.0 failed', 16,1)
RETURN
END
EXEC @result = sp_OAMethod @object, 'open', NULL, 'GET', @URI, false
IF @result <>0
BEGIN
RAISERROR('sp_OAMethod Open failed', 16,1)
RETURN
END
EXEC @result = sp_OAMethod @object, SEND, NULL, ''
IF @result <>0
BEGIN
RAISERROR('sp_OAMethod SEND failed', 16,1)
RETURN
END
EXEC @result = sp_OAGetProperty @object,
'responseText', @output_XML OUTPUT
IF @result <>0
BEGIN
RAISERROR('sp_OAGetProperty responseText failed', 16,1)
RETURN
END
SELECT @output_XML StockQouteXML
IF @result <>0
BEGIN
RAISERROR('sp_OAGetProperty responseText failed', 16,1)
RETURN
END
SELECT @output_XML StockQouteXML
EXEC @result = sp_OADestroy @object
IF @result <>0
BEGIN
RAISERROR('sp_OAGetProperty responseText failed', 16,1)
RETURN
END
IF @result <>0
BEGIN
RAISERROR('sp_OAGetProperty responseText failed', 16,1)
RETURN
END
It works
ReplyDeletethanks to U
ReplyDeleteDeclare @Object as Int;
ReplyDeleteDeclare @ResponseText as Varchar(MAX);
Declare @ResponseXml as Varchar(8000);
Declare @ResponseBody as Varchar(8000);
Declare @Status as INT
Declare @StatusText AS VARCHAR(512)
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get', 'http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=india','false'
Exec sp_OAMethod @Object, 'send'
SELECT @Object
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Select @ResponseText
Exec sp_OADestroy @Object
getting null value.....can you help me