VirtualBox

Changeset 22666 in vbox


Ignore:
Timestamp:
Sep 1, 2009 2:03:51 PM (15 years ago)
Author:
vboxsync
Message:

webservice: add webtest logoff command, docs, cleanup

Location:
trunk/src/VBox/Main/webservice
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r22266 r22666  
    33 *      hand-coded parts of the webservice server. This is linked with the
    44 *      generated code in out/.../src/VBox/Main/webservice/methodmaps.cpp
    5  *      (and static gSOAP server code) to implement the actual webservice
     5 *      (plus static gSOAP server code) to implement the actual webservice
    66 *      server, to which clients can connect.
    77 *
     
    9898                        *g_pcszIVirtualBox;
    9999
     100// globals for vboxweb command-line arguments
    100101#define DEFAULT_TIMEOUT_SECS 300
    101102#define DEFAULT_TIMEOUT_SECS_STRING "300"
    102 
    103103int                     g_iWatchdogTimeoutSecs = DEFAULT_TIMEOUT_SECS;
    104104int                     g_iWatchdogCheckInterval = 5;
    105105
    106 const char              *g_pcszBindToHost = NULL;        // host; NULL = current machine
     106const char              *g_pcszBindToHost = NULL;       // host; NULL = current machine
    107107unsigned int            g_uBindToPort = 18083;          // port
    108108unsigned int            g_uBacklog = 100;               // backlog = max queue size for requests
     
    205205}
    206206
     207/**
     208 * Implementation for WEBLOG macro defined in vboxweb.h; this prints a message
     209 * to the console and optionally to the file that may have been given to the
     210 * vboxwebsrv command line.
     211 * @param pszFormat
     212 */
    207213void WebLog(const char *pszFormat, ...)
    208214{
     
    223229}
    224230
     231/**
     232 * Helper for printing SOAP error messages.
     233 * @param soap
     234 */
    225235void WebLogSoapError(struct soap *soap)
    226236{
     
    241251/**
    242252 * Start up the webservice server. This keeps running and waits
    243  * for incoming SOAP connections.
     253 * for incoming SOAP connections; for each request that comes in,
     254 * it calls method implementation code, most of it in the generated
     255 * code in methodmaps.cpp.
    244256 *
    245257 * @param argc
     
    417429               m);
    418430
    419         for (unsigned long long i = 1;
     431        for (uint64_t i = 1;
    420432             ;
    421433             i++)
    422434        {
     435            // call gSOAP to handle incoming SOAP connection
    423436            s = soap_accept(&soap);
    424437            if (s < 0)
     
    479492    {
    480493        WEBDEBUG(("Watchdog: sleeping %d seconds\n", g_iWatchdogCheckInterval));
    481         RTThreadSleep(g_iWatchdogCheckInterval*1000);
     494        RTThreadSleep(g_iWatchdogCheckInterval * 1000);
    482495
    483496        time_t                      tNow;
     
    570583    ex->badObjectID = obj;
    571584
    572     /* std::ostringstream ostr;
    573     ostr << std::hex << ex->badObjectID; */
    574 
    575585    std::string str("VirtualBox error: ");
    576586    str += "Invalid managed object reference \"" + obj + "\"";
  • trunk/src/VBox/Main/webservice/vboxweb.h

    r21878 r22666  
    2626void WebLog(const char *pszFormat, ...);
    2727
    28 // #ifdef DEBUG
    2928#define WEBDEBUG(a) if (g_fVerbose) { WebLog a; }
    30 // #else
    31 // #define WEBDEBUG(a) do { } while(0)
    32 // #endif
    3329
    3430/****************************************************************************
     
    3834 ****************************************************************************/
    3935
    40 extern ComPtr<IVirtualBox> G_pVirtualBox;
     36extern ComPtr<IVirtualBox> g_pVirtualBox;
    4137extern bool g_fVerbose;
    4238
     
    5349typedef std::string vbox__uuid;
    5450
    55 // type used internally by our class
    56 // typedef WSDLT_ID ManagedObjectID;
    57 
    58 // #define VBOXWEB_ERROR_BASE                      10000
    59 // #define VBOXWEB_INVALID_MANAGED_OBJECT          (VBOXWEB_ERROR_BASE + 0)
    60 // #define VBOXWEB_INVALID_MANAGED_OBJECT_TYPE     (VBOXWEB_ERROR_BASE + 1)
    61 
    6251/****************************************************************************
    6352 *
     
    9079
    9180/**
    92  *
     81 *  An instance of this gets created for every client that logs onto the
     82 *  webservice (via the special IWebsessionManager::logon() SOAP API) and
     83 *  maintains the managed object references for that session.
    9384 */
    9485class WebServiceSession
     
    9889    private:
    9990        uint64_t                    _uSessionID;
    100         WebServiceSessionPrivate    *_pp;
     91        WebServiceSessionPrivate    *_pp;               // opaque data struct (defined in vboxweb.cpp)
    10192        bool                        _fDestructing;
    10293
     
    228219        if (fNullAllowed && pRef == NULL)
    229220        {
    230           pComPtr.setNull();
    231           return 0;
     221            pComPtr.setNull();
     222            return 0;
    232223        }
    233224
    234225        // pRef->getComPtr returns a ComPtr<IUnknown>; by casting it to
    235         // ComPtr<T>, we implicitly do a queryInterface() call
     226        // ComPtr<T>, we implicitly do a COM queryInterface() call
    236227        if (pComPtr = pRef->getComPtr())
    237228            return 0;
     
    266257    }
    267258
    268     WebServiceSession* pSession;
     259    WebServiceSession *pSession;
    269260    if ((pSession = WebServiceSession::findSessionFromRef(idParent)))
    270261    {
  • trunk/src/VBox/Main/webservice/webtest.cpp

    r18423 r22666  
    4747               "Usage:\n"
    4848               " - IWebsessionManager:\n"
    49                "   - webtest logon <user> <pass>: IWebsessionManage::logon().\n"
    50                "   - webtest getsession <vboxref>: IWebsessionManage::getSessionObject().\n"
     49               "   - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
     50               "   - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
     51               "   - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
    5152               " - IVirtualBox:\n"
    5253               "   - webtest version <vboxref>: IVirtualBox::getVersion().\n"
     
    8485            req.username = argv[2];
    8586            req.password = argv[3];
    86             std::cout << "logon: user = \"" << req.username << "\", pass = \"" << req.password << "\"\n";
    8787            _vbox__IWebsessionManager_USCORElogonResponse resp;
    8888
     
    111111                                                            &resp)))
    112112                std::cout << "session: \"" << resp.returnval << "\"\n";
     113        }
     114    }
     115    else if (!strcmp(pcszMode, "logoff"))
     116    {
     117        if (argc < 3)
     118            std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
     119        else
     120        {
     121            _vbox__IWebsessionManager_USCORElogoff req;
     122            req.refIVirtualBox = argv[2];
     123            _vbox__IWebsessionManager_USCORElogoffResponse resp;
     124
     125            if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogoff(&soap,
     126                                                            pcszArgEndpoint,
     127                                                            NULL,
     128                                                            &req,
     129                                                            &resp)))
     130                ;
    113131        }
    114132    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette