webtest.cpp revision ebb33f3aef3b410579a2865109426b798b9d4a9d
/*
* webtest.cpp:
* demo webservice client in C++. This mimics some of the
* functionality of VBoxManage for testing purposes.
*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
// gSOAP headers (must come after vbox includes because it checks for conflicting defs)
#include "soapStub.h"
// include generated namespaces table
#include "vboxwebsrv.nsmap"
#include <iostream>
#include <sstream>
#include <string>
{
"webtest: VirtualBox webservice testcase.\n"
"\nUsage: webtest [options] [command]...\n"
"\nSupported options:\n"
" -h: print this help message and exit.\n"
" -c URL: specify the webservice server URL (default http://localhost:18083/).\n"
"\nSupported commands:\n"
" - IWebsessionManager:\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"
" - webtest gethost <vboxref>: IVirtualBox::getHost().\n"
" - webtest getpc <vboxref>: IVirtualBox::getPerformanceCollector().\n"
" - webtest getmachines <vboxref>: IVirtualBox::getMachines().\n"
" - webtest createmachine <vboxref> <settingsPath> <name>: IVirtualBox::createMachine().\n"
" - webtest registermachine <vboxref> <machineref>: IVirtualBox::registerMachine().\n"
" - IHost:\n"
" - webtest getdvddrives <hostref>: IHost::getDVDDrives.\n"
" - IHostDVDDrive:\n"
" - webtest getdvdname <dvdref>: IHostDVDDrive::getname.\n"
" - IMachine:\n"
" - webtest getname <machineref>: IMachine::getName().\n"
" - webtest getid <machineref>: IMachine::getId().\n"
" - webtest getostype <machineref>: IMachine::getGuestOSType().\n"
" - webtest savesettings <machineref>: IMachine::saveSettings().\n"
" - IPerformanceCollector:\n"
" - webtest setupmetrics <pcref>: IPerformanceCollector::setupMetrics()\n"
" - webtest querymetricsdata <pcref>: IPerformanceCollector::QueryMetricsData()\n"
" - IVirtualBoxErrorInfo:\n"
" - webtest errorinfo <eiref>: various IVirtualBoxErrorInfo getters\n"
" - All managed object references:\n"
" - webtest getif <ref>: report interface of object.\n"
" - webtest release <ref>: IUnknown::Release().\n";
}
/**
*
* @param argc
* @param argv[]
* @return
*/
{
bool fSSL = false;
const char *pcszArgEndpoint = "http://localhost:18083/";
int ap;
{
{
usage(0);
{
ap++;
usage(1);
}
else
usage(1);
}
else
break;
}
usage(1);
#ifdef WITH_OPENSSL
if (fSSL)
#endif /* WITH_OPENSSL */
#ifdef WITH_OPENSSL
// Use SOAP_SSL_NO_AUTHENTICATION here to accept broken server configs.
// In a real world setup please use at least SOAP_SSL_DEFAULT and provide
// the necessary CA certificate for validating the server's certificate.
NULL /*randfile*/))
{
exit(1);
}
#endif /* WITH_OPENSSL */
int soaprc = SOAP_SVR_FAULT;
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
{
;
}
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
{
}
}
}
{
else
{
NULL,
&req,
&resp)))
{
}
}
}
{
else
{
NULL,
&req,
&resp)))
{
for (size_t i = 0;
i < c;
++i)
{
}
}
}
}
{
else
{
std::cout << "createmachine: settingsFile = \"" << req.settingsFile << "\", name = \"" << req.name << "\"\n";
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
{
for (size_t i = 0;
i < c;
++i)
{
}
}
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
{
else
{
// req.metricNames[0] = "*";
// req.objects
NULL,
&req,
&resp)))
{
for (size_t i = 0;
i < c;
++i)
{
}
}
}
}
{
else
{
// req.metricNames[0] = "*";
// req.objects
NULL,
&req,
&resp)))
{
for (size_t i = 0;
i < c;
++i)
{
}
}
}
}
{
else
{
NULL,
&req,
&resp)))
{
NULL,
&req2,
&resp2)))
{
NULL,
&req3,
&resp3)))
}
}
}
}
{
else
{
NULL,
&req,
&resp)))
}
}
else
if (soaprc)
{
)
{
// generic fault message whether the fault is known or not
{
std::cerr << "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n";
}
{
std::cerr << "Result code: 0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n";
}
}
else
{
}
}
return soaprc;
}