Index: /trunk/src/VBox/Main/webservice/vboxweb.cpp
===================================================================
--- /trunk/src/VBox/Main/webservice/vboxweb.cpp	(revision 22665)
+++ /trunk/src/VBox/Main/webservice/vboxweb.cpp	(revision 22666)
@@ -3,5 +3,5 @@
  *      hand-coded parts of the webservice server. This is linked with the
  *      generated code in out/.../src/VBox/Main/webservice/methodmaps.cpp
- *      (and static gSOAP server code) to implement the actual webservice
+ *      (plus static gSOAP server code) to implement the actual webservice
  *      server, to which clients can connect.
  *
@@ -98,11 +98,11 @@
                         *g_pcszIVirtualBox;
 
+// globals for vboxweb command-line arguments
 #define DEFAULT_TIMEOUT_SECS 300
 #define DEFAULT_TIMEOUT_SECS_STRING "300"
-
 int                     g_iWatchdogTimeoutSecs = DEFAULT_TIMEOUT_SECS;
 int                     g_iWatchdogCheckInterval = 5;
 
-const char              *g_pcszBindToHost = NULL;        // host; NULL = current machine
+const char              *g_pcszBindToHost = NULL;       // host; NULL = current machine
 unsigned int            g_uBindToPort = 18083;          // port
 unsigned int            g_uBacklog = 100;               // backlog = max queue size for requests
@@ -205,4 +205,10 @@
 }
 
+/**
+ * Implementation for WEBLOG macro defined in vboxweb.h; this prints a message
+ * to the console and optionally to the file that may have been given to the
+ * vboxwebsrv command line.
+ * @param pszFormat
+ */
 void WebLog(const char *pszFormat, ...)
 {
@@ -223,4 +229,8 @@
 }
 
+/**
+ * Helper for printing SOAP error messages.
+ * @param soap
+ */
 void WebLogSoapError(struct soap *soap)
 {
@@ -241,5 +251,7 @@
 /**
  * Start up the webservice server. This keeps running and waits
- * for incoming SOAP connections.
+ * for incoming SOAP connections; for each request that comes in,
+ * it calls method implementation code, most of it in the generated
+ * code in methodmaps.cpp.
  *
  * @param argc
@@ -417,8 +429,9 @@
                m);
 
-        for (unsigned long long i = 1;
+        for (uint64_t i = 1;
              ;
              i++)
         {
+            // call gSOAP to handle incoming SOAP connection
             s = soap_accept(&soap);
             if (s < 0)
@@ -479,5 +492,5 @@
     {
         WEBDEBUG(("Watchdog: sleeping %d seconds\n", g_iWatchdogCheckInterval));
-        RTThreadSleep(g_iWatchdogCheckInterval*1000);
+        RTThreadSleep(g_iWatchdogCheckInterval * 1000);
 
         time_t                      tNow;
@@ -570,7 +583,4 @@
     ex->badObjectID = obj;
 
-    /* std::ostringstream ostr;
-    ostr << std::hex << ex->badObjectID; */
-
     std::string str("VirtualBox error: ");
     str += "Invalid managed object reference \"" + obj + "\"";
Index: /trunk/src/VBox/Main/webservice/vboxweb.h
===================================================================
--- /trunk/src/VBox/Main/webservice/vboxweb.h	(revision 22665)
+++ /trunk/src/VBox/Main/webservice/vboxweb.h	(revision 22666)
@@ -26,9 +26,5 @@
 void WebLog(const char *pszFormat, ...);
 
-// #ifdef DEBUG
 #define WEBDEBUG(a) if (g_fVerbose) { WebLog a; }
-// #else
-// #define WEBDEBUG(a) do { } while(0)
-// #endif
 
 /****************************************************************************
@@ -38,5 +34,5 @@
  ****************************************************************************/
 
-extern ComPtr<IVirtualBox> G_pVirtualBox;
+extern ComPtr<IVirtualBox> g_pVirtualBox;
 extern bool g_fVerbose;
 
@@ -53,11 +49,4 @@
 typedef std::string vbox__uuid;
 
-// type used internally by our class
-// typedef WSDLT_ID ManagedObjectID;
-
-// #define VBOXWEB_ERROR_BASE                      10000
-// #define VBOXWEB_INVALID_MANAGED_OBJECT          (VBOXWEB_ERROR_BASE + 0)
-// #define VBOXWEB_INVALID_MANAGED_OBJECT_TYPE     (VBOXWEB_ERROR_BASE + 1)
-
 /****************************************************************************
  *
@@ -90,5 +79,7 @@
 
 /**
- *
+ *  An instance of this gets created for every client that logs onto the
+ *  webservice (via the special IWebsessionManager::logon() SOAP API) and
+ *  maintains the managed object references for that session.
  */
 class WebServiceSession
@@ -98,5 +89,5 @@
     private:
         uint64_t                    _uSessionID;
-        WebServiceSessionPrivate    *_pp;
+        WebServiceSessionPrivate    *_pp;               // opaque data struct (defined in vboxweb.cpp)
         bool                        _fDestructing;
 
@@ -228,10 +219,10 @@
         if (fNullAllowed && pRef == NULL)
         {
-          pComPtr.setNull();
-          return 0;
+            pComPtr.setNull();
+            return 0;
         }
 
         // pRef->getComPtr returns a ComPtr<IUnknown>; by casting it to
-        // ComPtr<T>, we implicitly do a queryInterface() call
+        // ComPtr<T>, we implicitly do a COM queryInterface() call
         if (pComPtr = pRef->getComPtr())
             return 0;
@@ -266,5 +257,5 @@
     }
 
-    WebServiceSession* pSession;
+    WebServiceSession *pSession;
     if ((pSession = WebServiceSession::findSessionFromRef(idParent)))
     {
Index: /trunk/src/VBox/Main/webservice/webtest.cpp
===================================================================
--- /trunk/src/VBox/Main/webservice/webtest.cpp	(revision 22665)
+++ /trunk/src/VBox/Main/webservice/webtest.cpp	(revision 22666)
@@ -47,6 +47,7 @@
                "Usage:\n"
                " - IWebsessionManager:\n"
-               "   - webtest logon <user> <pass>: IWebsessionManage::logon().\n"
-               "   - webtest getsession <vboxref>: IWebsessionManage::getSessionObject().\n"
+               "   - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
+               "   - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
+               "   - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
                " - IVirtualBox:\n"
                "   - webtest version <vboxref>: IVirtualBox::getVersion().\n"
@@ -84,5 +85,4 @@
             req.username = argv[2];
             req.password = argv[3];
-            std::cout << "logon: user = \"" << req.username << "\", pass = \"" << req.password << "\"\n";
             _vbox__IWebsessionManager_USCORElogonResponse resp;
 
@@ -111,4 +111,22 @@
                                                             &resp)))
                 std::cout << "session: \"" << resp.returnval << "\"\n";
+        }
+    }
+    else if (!strcmp(pcszMode, "logoff"))
+    {
+        if (argc < 3)
+            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
+        else
+        {
+            _vbox__IWebsessionManager_USCORElogoff req;
+            req.refIVirtualBox = argv[2];
+            _vbox__IWebsessionManager_USCORElogoffResponse resp;
+
+            if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogoff(&soap,
+                                                            pcszArgEndpoint,
+                                                            NULL,
+                                                            &req,
+                                                            &resp)))
+                ;
         }
     }
