Example 2

This example invokes a Web method to display stock information within an XML document.

Use the add option of sp_webservices to map Web methods to proxy tables:

1> sp_webservices "add" , "http://www.webservicex.net/stockquote.asmx?WSDL"
2> go

The Web method GetQuote1 is mapped to a proxy table of the same name.

Invoke the Web method by selecting the outxml column of the GetQuote1 proxy table:

1> select outxml from GetQuote1 where _inxml = '<?xml version="1.0" encoding="utf-8"?>
2>     <GetQuote1 xmlns="http://www.webserviceX.NET/">
3>       <symbol>SY</symbol>
4>     </GetQuote1>'
5> go

The results for the previous select display quote information within an XML document:

 outxml

<?xml version="1.0" encoding="UTF-8" ?><GetQuote1Response
xmlns="http://www.webserviceX.NET/"><GetQuoteResult><StockQuotes><Stock><Symb
ol>SY</Symbol><Last>21.48</Last><Date>7/21/2005</Date><Time>4:01pm</Time><Cha
nge>+1.72</Change><Open>20.00</Open><High>21.60</High><Low>19.91</Low><Volume
>2420100</Volume><MktCap>1.927B</MktCap><PreviousClose>19.76</PreviousClose><
PercentageChange>+8.70%</PercentageChange><AnnRange>12.75 - 
20.44</AnnRange><Earns>0.706</Earns><P-E>27.99</P-E><Name>SYBASE 
INC</Name></Stock></StockQuotes></GetQuoteResult></GetQuote1Response>

(1 row affected)