This example invokes the GetQuote Web method, mapped to a proxy table in the previous example, through a view to display stock information.
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("ORCL") 3> go
Now create a view that invokes the GetQuote Web method:
1> CREATE VIEW getstockvw as 2> select Symbol = xmlextract('//Stock/Symbol/text()',outxml returns varchar(5)), 3> Name = xmlextract('//Stock/Name/text()',outxml returns varchar(20)), 4> Time = xmlextract('//Stock/Time/text()',outxml returns varchar(10)), 5> Date = xmlextract('//Stock/Date/text()',outxml returns date), 6> High = xmlextract('//Stock/High/text()',outxml returns decimal(15,2)), 7> Low = xmlextract('//Stock/Low/text()',outxml returns decimal(15,2)) 8> FROM GetQuote ,stocksymbol 9> WHERE _inxml = '<GetQuote xmlns="http://www.webserviceX.NET/"><symbol>'+symbol+'</symbol></GetQuote>' 10> go
Select from the getstockvw view to view output from the GetQuotes method:
1> select * from getstockvw 2> go
The results for the previous select display quote information for the parameters specified by the view definition:
Symbol Name Time Date High Low ------- ------------- ------- ------------ ------ ------ SY SYBASE INC 4:01pm Jul 21 2005 21.60 19.91 ORCL ORACLE CORP 4:00pm Jul 21 2005 14.05 13.54 MSFT MICROSOFT CP 4:00pm Jul 21 2005 26.48 26.19 (3 rows affected)