Version 7 of SOAP - hello world

Updated 2006-04-12 16:36:39

John Seal posted this hello world example for SOAP on comp.lang.tcl. tjk


Here's a "Hello, world!" example. First the server:

 package require SOAP::Domain

 namespace eval YourNamespace {

    proc iam {name} {
       return "Hello, $name!"
    }

    SOAP::export iam

 }

 SOAP::Domain::register -prefix /yourPrefix \
     -namespace YourNamespace \
     -uri YourNamespace

Put the server in the CGI directory of your webserver (tclhttpd works great if you don't already have one). Now the client:

 package require SOAP

 SOAP::create iam \
    -uri YourNamespace \
    -proxy http://localhost:8015/yourPrefix \
    -params {name string}

Now invoke the procedure in the client:

 (sandbox) 1 % iam busirane
 Hello, busirane!

snichols Too funny. Nice way to demonstrate SOAP. The reality is that many real world business SOAP web services use complex SOAP data types that's difficult to program Tcl clients against without creating your own SOAP wrappers.

Category Internet | Category Interprocess Communication | Category XML