This example invokes a Web method through a view to display stock information.
This example requires the ASE XML Management Option
Package.
To use this Web service, you must create a table to hold symbols representing stocks:
1> create table stocksymbol(symbol varchar(100)) 2> go
Insert data into the stocksymbol table:
1> insert stocksymbol values("SY") 2> insert stocksymbol values("PSFT") 3> insert stocksymbol values("ORCL") 4> insert stocksymbol values("MSFT") 5> insert stocksymbol values("SUNW") 6> go
Use the add option of sp_webservices to map Web methods to proxy tables:
1>sp_webservices "add" , "http://www.xignite.com/xquotes.asmx?WSDL" , ws 2>go
Fifteen Web methods are mapped to proxy tables. One of these Web methods is named GetQuotes.
Now create a view that invokes the GetQuotes Web method:
1> CREATE VIEW getstockvw as SELECT Symbol = xmlextract('//Quote/Symbol/text()',outxml returns varchar(10)), Name = xmlextract('//Quote/Name/text()',outxml returns varchar(100)), Date = xmlextract('//Quote/Date/text()',outxml returns date), Time = xmlextract('//Quote/Time/text()',outxml returns varchar(25)), Openval = xmlextract('//Quote/Open/text()',outxml returns decimal(15,3)), High = xmlextract('//Quote/High/text()',outxml returns decimal(15,3)), Low = xmlextract('//Quote/Low/text()',outxml returns decimal(15,3)), Last = xmlextract('//Quote/Last/text()',outxml returns decimal(15,3)), Volume = xmlextract('//Quote/Volume/text()',outxml returns decimal(15,3)), PercentChange = xmlextract('//Quote/PercentChange/text()',outxml returns decimal(15,3)) FROM GetQuotes ,stocksymbol WHERE _inxml ='<GetQuotes xmlns="http://www.xignite.com/services/"> <Symbol>'+symbol+'</Symbol> </GetQuotes>' 2> go
Select from the getstockvw view to view output from the GetQuotes method:
1> select * from getstockvw where Symbol in ('SY','ORCL') 2> go Symbol Name Date Time Openval High Low Last Volume PercentChange ------ ----- ---- ---- ------- ---- --- ---- ------- ----------- SY SYBASE INC Feb 11 2004 2:55PM ET 22.22 22.53 22.03 22.53 344600.00 1.40 ORCL ORACLE CORP Feb 11 2004 3:00PM ET 13.53 13.79 13.33 13.73 29931784.00 2.54 (2 rows affected)
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |