home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / demos / TclSOAP / SOAP-tests.tcl < prev    next >
Encoding:
Text File  |  2001-10-22  |  9.1 KB  |  265 lines

  1. # SOAP-tests.tcl - Copyright (C) 2001 Pat Thoyts <Pat.Thoyts@bigfoot.com>
  2. #
  3. # Create some remote SOAP access methods to demo servers.
  4. #
  5. # If you live behind a firewall and have an authenticating proxy web server
  6. # try executing SOAP::proxyconfig and filling in the fields. This sets
  7. # up the SOAP package to send the correct headers for the proxy to 
  8. # forward the packets (provided it is using the `Basic' encoding scheme).
  9. #
  10. # The SOAP::Lite project has some nice examples of object access that
  11. # we should pursue
  12. # -------------------------------------------------------------------------
  13. # This software is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15. # or FITNESS FOR A PARTICULAR PURPOSE.  See the accompanying file `LICENSE'
  16. # for more details.
  17. # -------------------------------------------------------------------------
  18. #
  19. # @(#)$Id: SOAP-tests.tcl,v 1.13 2001/08/01 23:47:06 patthoyts Exp $
  20.  
  21. package require SOAP
  22.  
  23. # -------------------------------------------------------------------------
  24. # Validators
  25. #
  26. # Microsoft provide a .NET client validator
  27. SOAP::create validator1 \
  28.         -name "validate" \
  29.         -uri "urn:zsplat-Validator" \
  30.         -proxy "http://www.soaptoolkit.com/soapvalidator/listener.asp" \
  31.         -params { msg string num integer }
  32.  
  33. SOAP::create validator2 \
  34.         -name "validate" \
  35.         -uri "urn:zsplat-Validator" \
  36.         -action "\"\"" \
  37.         -proxy "http://www.soaptoolkit.com/soapvalidator/listener.asp" \
  38.         -params { msg string num integer }
  39.  
  40. SOAP::create validator3 \
  41.         -name "validate" \
  42.         -uri "urn:zsplat-Validator" \
  43.         -action "urn:tclsoap-Test" \
  44.         -proxy "http://www.soaptoolkit.com/soapvalidator/listener.asp" \
  45.         -params {myStruct struct}
  46.  
  47. # -------------------------------------------------------------------------
  48. #
  49. # XMethods demos (www.xmethods.net)
  50. #
  51. SOAP::create getTemp \
  52.         -uri "urn:xmethods-Temperature" \
  53.         -proxy "http://services.xmethods.net/soap/servlet/rpcrouter" \
  54.         -params { "zipcode" "string" }
  55.  
  56. SOAP::create pingHost \
  57.         -proxy "http://services.xmethods.net:80/perl/soaplite.cgi" \
  58.         -uri "urn:xmethodsSoapPing" \
  59.         -params { "hostname" "string" }
  60.  
  61. SOAP::create getTraffic \
  62.         -proxy "http://services.xmethods.net:80/soap/servlet/rpcrouter" \
  63.         -uri "urn:xmethods-CATraffic" \
  64.         -params { "hwaynum" "string" }
  65.  
  66. SOAP::create checkDomain \
  67.         -uri "urn:xmethods-DomainChecker" \
  68.         -proxy "http://services.xmethods.net:9090/soap" \
  69.         -params { "domainname" "string" }
  70.  
  71. # -------------------------------------------------------------------------
  72. #
  73. # SOAP::Lite Perl demos (www.soaplite.com)
  74. #
  75. SOAP::create hi \
  76.         -uri "http://www.soaplite.com/Demo" \
  77.         -proxy "http://services.soaplite.com/hibye.cgi" \
  78.         -params {}
  79.  
  80. SOAP::create hello \
  81.         -name hi \
  82.         -uri "http://www.soaplite.com/Demo" \
  83.         -proxy "http://services.soaplite.com/hibye.cgi" \
  84.         -params {}
  85.  
  86. SOAP::create languages \
  87.         -uri "http://www.soaplite.com/Demo" \
  88.         -proxy "http://services.soaplite.com/hibye.cgi" \
  89.         -params {}
  90.  
  91. SOAP::create f2c \
  92.         -uri "http://www.soaplite.com/Temperatures" \
  93.         -proxy "http://services.soaplite.com/temper.cgi" \
  94.         -params { "temp" "float"}
  95.  
  96. SOAP::create c2f \
  97.         -uri "http://www.soaplite.com/Temperatures" \
  98.         -proxy "http://services.soaplite.com/temper.cgi" \
  99.         -params { "temp" "float"}
  100.  
  101. # Call with the wrong method name evokes a SOAP Fault packet.
  102. SOAP::create c2f_broke \
  103.         -uri "http://www.soaplite.com/Temperatures" \
  104.         -proxy "http://services.soaplite.com/temper.cgi" \
  105.         -params { "temp" "float"}\
  106.         -name c2f_invalid
  107.  
  108. # -------------------------------------------------------------------------
  109. #
  110. # Lucin
  111. #
  112. SOAP::create getCard \
  113.         -uri "GetACard" \
  114.         -name "GetACard" \
  115.         -proxy "http://sal006.salnetwork.com:82/bin/games.cgi" \
  116.         -params {}
  117.  
  118. SOAP::create getHand \
  119.         -uri "GetAHand" \
  120.         -name "GetAHand" \
  121.         -proxy "http://sal006.salnetwork.com:82/bin/games.cgi" \
  122.         -params {}
  123.  
  124. # -------------------------------------------------------------------------
  125. #
  126. # Other demos
  127. #
  128. SOAP::create NextGUID \
  129.         -uri "http://www.itfinity.net/soap/guid/guid.xsd" \
  130.         -proxy "http://www.itfinity.net/soap/guid/default.asp" \
  131.         -params {}
  132.  
  133. SOAP::create whois \
  134.         -uri "http://www.pocketsoap.com/whois" \
  135.         -proxy "http://www.razorsoft.net/ssss4c/whois.asp" \
  136.         -params { "name" "string" }
  137.  
  138. SOAP::create census \
  139.         -uri "http://tempuri.org/" \
  140.         -proxy "http://terranet.research.microsoft.com/CensusService.asmx" \
  141.         -params { "pu" "string" "name" "string" \
  142.                   "ParentName" "string" "year" "integer" } \
  143.         -action "http://tempuri.org/GetPoliticalUnitFactsByName" \
  144.         -name GetPoliticalUnitFactsByName
  145.  
  146.  
  147. # Babelfish translator http://www.xmltoday.com/examples/soap/translate.psp
  148.  
  149. SOAP::create translate \
  150.         -action urn:vgx-translate \
  151.         -name getTranslation \
  152.         -proxy http://www.velocigen.com:82/vx_engine/soap-trigger.pperl \
  153.         -uri urn:vgx-translate \
  154.         -params {"text" "string" "language" "string"}
  155.  
  156. # translate {Good morning} en_[de|fr|it|es|pt]
  157. # translate {Guten tag} de_fr
  158.  
  159. SOAP::create news \
  160.         -name ProcessSRL \
  161.         -proxy http://www.soapclient.com/xml/SQLDataSoap.wsdl \
  162.         -params {SRLFile string RequestName string} \
  163.         -uri http://www.soapclient.com/xml/SQLDataSoap.xsd \
  164.         -action "/SQLDataSRL"
  165.  
  166. # Never replies with any data.
  167. SOAP::create mp3 \
  168.         -name SearchMP3 \
  169.         -action urn:SoapFindMP3Intf-ISoapFindMP3#SearchMP3 \
  170.         -uri urn:SoapFindMP3Intf-ISoapFindMP3 \
  171.         -proxy http://www.agnisoft.com/cgi-bin/soapmp3search.exe/soap/ISoapFindMP3 \
  172.         -params {SearchString string NumResults int}
  173.  
  174. # -------------------------------------------------------------------------
  175.  
  176. # Fortune server has 3 methods.
  177. namespace eval Fortune {
  178.     variable uri "urn:lemurlabs-Fortune"
  179.     variable proxy "http://www.lemurlabs.com:80/rpcrouter"
  180.  
  181.     proc unxml {methodVarName xml} {
  182.         regsub -all {<} $xml {<} xml
  183.         regsub -all {>} $xml {>} xml
  184.         regsub -all {&} $xml {&} xml
  185.         return $xml
  186.     }
  187.  
  188.     SOAP::create getAnyFortune -uri $uri -proxy $proxy -postProc unxml
  189.     SOAP::create getDictionaryNameList -uri $uri -proxy $proxy
  190.     SOAP::create getFortuneByDictionary -uri $uri -proxy $proxy \
  191.             -params { "dictionary" "string" } -postProc unxml
  192.     namespace export getAnyFortune getDictionaryNameList \
  193.             getFortuneByDictionary
  194. }
  195.  
  196. # -------------------------------------------------------------------------
  197.  
  198. namespace eval XFS {
  199.     variable uri "urn:xmethodsXFS"
  200.     variable proxy "http://services.xmethods.net:80/soap/servlet/rpcrouter"
  201.     SOAP::create readFile -uri $uri -proxy $proxy -params \
  202.             { "userid" "string" "filename" "string" "password" "string" }
  203.     SOAP::create writeFile -uri $uri -proxy $proxy -params \
  204.             { "userid" "string" \
  205.             "filedata" "string" \
  206.             "filename" "string" \
  207.             "password" "string" }
  208.     SOAP::create removeFile -uri $uri -proxy $proxy -params \
  209.             { "userid" "string" "filename" "string" "password" "string" }
  210.     SOAP::create listFiles -uri $uri -proxy $proxy -params \
  211.             { "userid" "string" "password" "string" }
  212.     namespace export readFile removeFile writeFile listFiles
  213. }
  214.  
  215. namespace eval Chat {
  216.     variable uri "http://tempuri.org/"
  217.     variable proxy "http://aspx.securewebs.com/prasadv/prasadchat.asmx"
  218.     SOAP::create RegisterMember -uri $uri -proxy $proxy \
  219.             -action "${uri}RegisterMember" \
  220.             -params { "NickName" "string" }
  221.     SOAP::create XchangeMsgs -uri $uri -proxy $proxy \
  222.             -action "${uri}XchangeMsgs" \
  223.             -params { "NickName" "string" "Msg" "string" }
  224.     SOAP::create GetMsgs -uri $uri -proxy $proxy \
  225.             -action "${uri}GetMsgs" \
  226.             -params { "NickName" "string" }
  227.     namespace export RegisterMember XchangeMsgs GetMsgs
  228. }
  229.  
  230. # -------------------------------------------------------------------------
  231.  
  232. namespace eval uddi {
  233.     variable uri "urn:uddi-org:api"
  234.     variable proxy "http://www-3.ibm.com/services/uddi/testregistry/inquiryapi"
  235.  
  236.     SOAP::create find_business -uri $uri -proxy $proxy -action {""} \
  237.             -params {name string}
  238.     
  239.     # takes one or more service key elements. (Why not an array of them?)
  240.     SOAP::create get_serviceDetail -uri $uri -proxy $proxy -action {""} \
  241.             -params {serviceKey string}
  242.  
  243.     # one or more key elements again.
  244.     SOAP::create get_bindingDetail -uri $uri -proxy $proxy -action {""} \
  245.             -params {bindingKey string}
  246.  
  247.  
  248.     proc showBI {who} {
  249.         set bilist [find_business $who]
  250.         foreach {label biData} $bilist {
  251.             array set businessInfo $biData
  252.             puts "$businessInfo(name): $businessInfo(description)"
  253.         }
  254.     }
  255.  
  256.     namespace export find_business get_serviceDetail get_bindingDetail
  257. }
  258.  
  259. # -------------------------------------------------------------------------
  260.  
  261.  
  262. # Local variables:
  263. #   indent-tabs-mode: nil
  264. # End: