This page contains examples of how to use the „Web services for Tcl“ [http://core.tcl.tk/tclws/index] client side package. The package was created and is maintained by Gerald Lester, who also patiently provides support for ignorant users. The client parses so-called [wsdl] files [http://en.wikipedia.org/wiki/Wsdl]. From this file you get all the information you need: * name of the web service * names of the operations it provides * parameters of the operations You may also get the information from the documentation of the service, or by a tool like soapUI, or by the CreateStubs command of the package (see below). The wsdl file contains the information in tags like === === Even those not familiar with wsdl can certainly identify the elements in this example (from the wsdl file "http://www.webservicex.net/country.asmx?WSDL") * the web service name is „country“ * the operation name is „GetCountryByCountryCode“ * the operation parameter is „CountryCode“ of type „string“ (in Tcl the type doesn't matter, of course) **Example 1: simple synchronous information retrieval** ====== package require Tcl 8.5 package require WS::Client ::WS::Client::GetAndParseWsdl "http://www.webservicex.net/MortgageIndex.asmx?WSDL" # DoCall: get result as a nested dict set monthlyIndex [ ::WS::Client::DoCall MortgageIndex GetCurrentMortgageIndexMonthly {} ] set key [ dict keys $monthlyIndex ] flush stdout puts "Key: $key" foreach { i v } [ dict get $monthlyIndex $key ] { puts "$i $v" } ====== should return something like === Key: GetCurrentMortgageIndexMonthlyResult IndexDate 7/1/2004 OneYearConstantMaturityTreasury 2.1 ThreeYearConstantMaturityTreasury 3.05 FiveYearConstantMaturityTreasury 3.69 ThreeMonthTreasuryBill 1.36 SixMonthTreasuryBill 1.69 ThreeMonthSecondaryMarketCD 1.4625 SixMonthSecondaryMarketCD - EleventhDistrictCOFI 1.4929 CostOfSavingsIndex 1.6945 OneMonthLIBOR 1.9857 ThreeMonthLIBOR 2.4632 SixMonthLIBOR 1.1617 OneYearLIBOR 1.91 CostOfDepositsIndex 1.57 TwelveMonthTreasuryAverage 1.85 === **See also** [Webservices] ***Other techniques*** [TclSOAP] [NOAA Weather Forecast] <> Example | Internet