Embeding a Web Service

Contents

Loading the Webservices Server Package

To load the webservices server package, do:

 package require WS::Embedded

This command will only load the server the first time it is used, so it causes no ill effects to put this in each file declaring a service or service procedure.


Specify a Port to Receive Request on

Procedure Name : ::WS::Embeded::Listen

Description : Instruct the module to listen on a Port, security information.

Arguments : this procedure uses position dependent arguments, they are:

     port     -- Port number to listen on.
     certfile -- Name of the certificate pem file for the tcltls package,
                 or a pfx certificate archive file for twapi TLS.
                 Defaults to {} (no TLS).
     keyfile  -- Name of the key pem file for the tcltls package.
                 Defaults to {}.
                 To use twapi TLS, specify a list with the following elements:
                    -twapi: fix flag, that TWAPI TLS should be used
                    password: password of PFX file passed by
                        [::twapi::conceal]. The concealing makes sure that the
                        password is not readable in the error stack trace
                    ?subject?: optional search string in pfx file, if
                        multiple certificates are included.
     userpwds -- A list of username:password. Defaults to {}.
     realm    -- The seucrity realm. Defaults to {}.

Returns : Handle of socket

Side-Effects : None

Exception Conditions :  : None

Pre-requisite Conditions : None


Enter the event queue

To serve any requests, the interpreter must enter the event queue using, for example:

     vwait waitVariable

Stop the server

To stop serving requests, the server socket may be closed. The socket handle was returned by ::WS::Embeded::Listen. Optionally, the event queue may be stopped as follows:

     close $handle
     set waitVariable 1