webtest.cpp revision f6fd812d35e1100931d67e2f37b0e54ec3e91c6a
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * demo webservice client in C++. This mimics some of the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * functionality of VBoxManage for testing purposes.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Copyright (C) 2006-2009 Sun Microsystems, Inc.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * This file is part of VirtualBox Open Source Edition (OSE), as
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * available from http://www.virtualbox.org. This file is free software;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * you can redistribute it and/or modify it under the terms of the GNU
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * General Public License (GPL) as published by the Free Software
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Foundation, in version 2 as it comes in the "COPYING" file of the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Clara, CA 95054 USA or visit http://www.sun.com if you need
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * additional information or have any questions.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs// gSOAP headers (must come after vbox includes because it checks for conflicting defs)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs// include generated namespaces table
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include "vboxwebsrv.nsmap"
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami * @param argc
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami * @param argv[]
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami soap_init(&soap); // initialize runtime environment (only once)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "webtest: VirtualBox webservice testcase.\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - IWebsessionManager:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - IVirtualBox:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest version <vboxref>: IVirtualBox::getVersion().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest gethost <vboxref>: IVirtualBox::getHost().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getmachines <vboxref>: IVirtualBox::getMachines().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest createmachine <vboxref> <baseFolder> <name>: IVirtualBox::createMachine().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest registermachine <vboxref> <machineref>: IVirtualBox::registerMachine().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - IHost:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getdvddrives <hostref>: IHost::getDVDDrives.\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - IHostDVDDrive:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getdvdname <dvdref>: IHostDVDDrive::getname.\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - IMachine:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getname <machineref>: IMachine::getName().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getid <machineref>: IMachine::getId().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getostype <machineref>: IMachine::getGuestOSType().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest savesettings <machineref>: IMachine::saveSettings().\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - All managed object references:\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest getif <ref>: report interface of object.\n"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs " - webtest release <ref>: IUnknown::Release().\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogon(&soap,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "VirtualBox objref: \"" << resp.returnval << "\"\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs _vbox__IWebsessionManager_USCOREgetSessionObject req;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs _vbox__IWebsessionManager_USCOREgetSessionObjectResponse resp;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (!(soaprc = soap_call___vbox__IWebsessionManager_USCOREgetSessionObject(&soap,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "session: \"" << resp.returnval << "\"\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogoff(&soap,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetVersion(&soap,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs std::cout << "version: \"" << resp.returnval << "\"\n";
0a44ef6d9afbfe052a7e975f55ea0d2954b62a82jacobs std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetHost(&soap,
NULL,
&req,
&resp)))
for (size_t i = 0;
std::cout << "createmachine: baseFolder = \"" << req.baseFolder << "\", name = \"" << req.name << "\"\n";
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
for (size_t i = 0;
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
NULL,
&req,
&resp)))
if (soaprc)
std::cout << "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n";
std::cout << "Result code: 0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n";
std::cout << "Component: " << std::hex << soap.fault->detail->vbox__RuntimeFault->component << "\n";
std::cout << "Interface ID: " << std::hex << soap.fault->detail->vbox__RuntimeFault->interfaceID << "\n";
return soaprc;