1#! /bin/sh 2# or /opt/TclPro1.4/win32-ix86/bin/tclsh83 3# 4# rpc - Copyright (C) 2001 Pat Thoyts <Pat.Thoyts@bigfoot.com> 5# 6# A CGI framework for SOAP and XML-RPC services from TclSOAP 7# 8# ------------------------------------------------------------------------- 9# This software is distributed in the hope that it will be useful, but 10# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11# or FITNESS FOR A PARTICULAR PURPOSE. See the accompanying file `LICENSE' 12# for more details. 13# ------------------------------------------------------------------------- 14# 15# restart using tclsh \ 16TCLLIBPATH="/home/pat/lib/tcl" \ 17exec tclsh "$0" ${1+"$@"} 18 19#set ::auto_path [linsert $::auto_path 0 {/home/pat/lib/tcl}] 20 21# ------------------------------------------------------------------------- 22 23# Description: 24# Write a complete html page to stdout, setting the content length correctly. 25# Notes: 26# The string length is incremented by the number of newlines as HTTP content 27# assumes CR-NL line endings. 28# 29proc write {html} { 30 puts "Content-Type: text/html" 31 set len [string length $html] 32 puts "X-Content-Length: $len" 33 incr len [regexp -all "\n" $html] 34 puts "Content-Length: $len" 35 36 puts "\n$html" 37 catch {flush stdout} 38} 39 40# ------------------------------------------------------------------------- 41 42if {[catch { 43 44 package require SOAP::CGI 45 46 # Set this to point to you SOAP service implementations. 47 set root [file join $::env(HOME) lib tcl tclsoap cgi-bin] 48 49 set SOAP::CGI::soapdir [file join $root soap] 50 set SOAP::CGI::soapmapfile [file join $root soapmap.dat] 51 set SOAP::CGI::xmlrpcdir [file join $root soap] 52 set SOAP::CGI::xmlrpcmapfile [file join $root xmlrpcmap.dat] 53 54 # Set this for some logging. 55 #set SOAP::CGI::logfile "../logs/rpc.log" 56 catch {unset SOAP::CGI::logfile} 57 58 SOAP::CGI::main 59 60} msg]} { 61 62 set html "<!doctype HTML public \"-//W3O//DTD W3 HTML 2.0//EN\">\n" 63 append html "<html>\n<head>\n<title>CGI Error</title>\n</head>\n<body>" 64 append html "<h1>CGI Error</h1>\n<p>$msg</p>\n" 65 append html "<br>\n<pre>$::errorInfo</pre>\n" 66 append html "</body>\n</html>" 67 write $html 68 69} 70 71# ------------------------------------------------------------------------- 72# 73# Local variables: 74# mode: tcl 75# End: 76