1 | /* $Id: webtest.cpp 69382 2017-10-26 16:38:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * webtest.cpp:
|
---|
4 | * demo webservice client in C++. This mimics some of the
|
---|
5 | * functionality of VBoxManage for testing purposes.
|
---|
6 | */
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | // gSOAP headers (must come after vbox includes because it checks for conflicting defs)
|
---|
20 | #include "soapStub.h"
|
---|
21 |
|
---|
22 | // include generated namespaces table
|
---|
23 | #include "vboxwebsrv.nsmap"
|
---|
24 |
|
---|
25 | #include <iostream>
|
---|
26 | #include <sstream>
|
---|
27 | #include <string>
|
---|
28 |
|
---|
29 | /* TEMPORARY! */
|
---|
30 | #if defined(_MSC_VER) && !defined(RT_ARCH_AMD64) && defined(DEBUG)
|
---|
31 | void wastesomecodespace(int a, int b, int c)
|
---|
32 | {
|
---|
33 | for (int i = 0; i < c ; i++)
|
---|
34 | a = a * b * c;
|
---|
35 | }
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | static void usage(int exitcode)
|
---|
39 | {
|
---|
40 | std::cout <<
|
---|
41 | "webtest: VirtualBox webservice testcase.\n"
|
---|
42 | "\nUsage: webtest [options] [command]...\n"
|
---|
43 | "\nSupported options:\n"
|
---|
44 | " -h: print this help message and exit.\n"
|
---|
45 | " -c URL: specify the webservice server URL (default http://localhost:18083/).\n"
|
---|
46 | "\nSupported commands:\n"
|
---|
47 | " - IWebsessionManager:\n"
|
---|
48 | " - webtest logon <user> <pass>: IWebsessionManager::logon().\n"
|
---|
49 | " - webtest getsession <vboxref>: IWebsessionManager::getSessionObject().\n"
|
---|
50 | " - webtest logoff <vboxref>: IWebsessionManager::logoff().\n"
|
---|
51 | " - IVirtualBox:\n"
|
---|
52 | " - webtest version <vboxref>: IVirtualBox::getVersion().\n"
|
---|
53 | " - webtest gethost <vboxref>: IVirtualBox::getHost().\n"
|
---|
54 | " - webtest getpc <vboxref>: IVirtualBox::getPerformanceCollector().\n"
|
---|
55 | " - webtest getmachines <vboxref>: IVirtualBox::getMachines().\n"
|
---|
56 | " - webtest createmachine <vboxref> <settingsPath> <name>: IVirtualBox::createMachine().\n"
|
---|
57 | " - webtest registermachine <vboxref> <machineref>: IVirtualBox::registerMachine().\n"
|
---|
58 | " - IHost:\n"
|
---|
59 | " - webtest getdvddrives <hostref>: IHost::getDVDDrives.\n"
|
---|
60 | " - IHostDVDDrive:\n"
|
---|
61 | " - webtest getdvdname <dvdref>: IHostDVDDrive::getname.\n"
|
---|
62 | " - IMachine:\n"
|
---|
63 | " - webtest getname <machineref>: IMachine::getName().\n"
|
---|
64 | " - webtest getid <machineref>: IMachine::getId().\n"
|
---|
65 | " - webtest getostype <machineref>: IMachine::getGuestOSType().\n"
|
---|
66 | " - webtest savesettings <machineref>: IMachine::saveSettings().\n"
|
---|
67 | " - IPerformanceCollector:\n"
|
---|
68 | " - webtest setupmetrics <pcref>: IPerformanceCollector::setupMetrics()\n"
|
---|
69 | " - webtest querymetricsdata <pcref>: IPerformanceCollector::QueryMetricsData()\n"
|
---|
70 | " - IVirtualBoxErrorInfo:\n"
|
---|
71 | " - webtest errorinfo <eiref>: various IVirtualBoxErrorInfo getters\n"
|
---|
72 | " - All managed object references:\n"
|
---|
73 | " - webtest getif <ref>: report interface of object.\n"
|
---|
74 | " - webtest release <ref>: IUnknown::Release().\n";
|
---|
75 | exit(exitcode);
|
---|
76 | }
|
---|
77 |
|
---|
78 | /**
|
---|
79 | *
|
---|
80 | * @param argc
|
---|
81 | * @param argv[]
|
---|
82 | * @return
|
---|
83 | */
|
---|
84 | int main(int argc, char* argv[])
|
---|
85 | {
|
---|
86 | bool fSSL = false;
|
---|
87 | const char *pcszArgEndpoint = "http://localhost:18083/";
|
---|
88 |
|
---|
89 | int ap;
|
---|
90 | for (ap = 1; ap < argc; ap++)
|
---|
91 | {
|
---|
92 | if (argv[ap][0] == '-')
|
---|
93 | {
|
---|
94 | if (!strcmp(argv[ap], "-h"))
|
---|
95 | usage(0);
|
---|
96 | else if (!strcmp(argv[ap], "-c"))
|
---|
97 | {
|
---|
98 | ap++;
|
---|
99 | if (ap >= argc)
|
---|
100 | usage(1);
|
---|
101 | pcszArgEndpoint = argv[ap];
|
---|
102 | fSSL = !strncmp(pcszArgEndpoint, "https://", 8);
|
---|
103 | }
|
---|
104 | else
|
---|
105 | usage(1);
|
---|
106 | }
|
---|
107 | else
|
---|
108 | break;
|
---|
109 | }
|
---|
110 |
|
---|
111 | if (argc < 1 + ap)
|
---|
112 | usage(1);
|
---|
113 |
|
---|
114 | #ifdef WITH_OPENSSL
|
---|
115 | if (fSSL)
|
---|
116 | soap_ssl_init();
|
---|
117 | #endif /* WITH_OPENSSL */
|
---|
118 |
|
---|
119 | struct soap soap; // gSOAP runtime environment
|
---|
120 | soap_init(&soap); // initialize runtime environment (only once)
|
---|
121 | #ifdef WITH_OPENSSL
|
---|
122 | // Use SOAP_SSL_NO_AUTHENTICATION here to accept broken server configs.
|
---|
123 | // In a real world setup please use at least SOAP_SSL_DEFAULT and provide
|
---|
124 | // the necessary CA certificate for validating the server's certificate.
|
---|
125 | if (fSSL && soap_ssl_client_context(&soap, SOAP_SSL_NO_AUTHENTICATION | SOAP_TLSv1,
|
---|
126 | NULL /*clientkey*/, NULL /*password*/,
|
---|
127 | NULL /*cacert*/, NULL /*capath*/,
|
---|
128 | NULL /*randfile*/))
|
---|
129 | {
|
---|
130 | soap_print_fault(&soap, stderr);
|
---|
131 | exit(1);
|
---|
132 | }
|
---|
133 | #endif /* WITH_OPENSSL */
|
---|
134 |
|
---|
135 | const char *pcszMode = argv[ap];
|
---|
136 | int soaprc = SOAP_SVR_FAULT;
|
---|
137 |
|
---|
138 | if (!strcmp(pcszMode, "logon"))
|
---|
139 | {
|
---|
140 | if (argc < 3 + ap)
|
---|
141 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
142 | else
|
---|
143 | {
|
---|
144 | _vbox__IWebsessionManager_USCORElogon req;
|
---|
145 | req.username = argv[ap + 1];
|
---|
146 | req.password = argv[ap + 2];
|
---|
147 | _vbox__IWebsessionManager_USCORElogonResponse resp;
|
---|
148 |
|
---|
149 | if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogon(&soap,
|
---|
150 | pcszArgEndpoint,
|
---|
151 | NULL,
|
---|
152 | &req,
|
---|
153 | &resp)))
|
---|
154 | std::cout << "VirtualBox objref: \"" << resp.returnval << "\"\n";
|
---|
155 | }
|
---|
156 | }
|
---|
157 | else if (!strcmp(pcszMode, "getsession"))
|
---|
158 | {
|
---|
159 | if (argc < 2 + ap)
|
---|
160 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
161 | else
|
---|
162 | {
|
---|
163 | _vbox__IWebsessionManager_USCOREgetSessionObject req;
|
---|
164 | req.refIVirtualBox = argv[ap + 1];
|
---|
165 | _vbox__IWebsessionManager_USCOREgetSessionObjectResponse resp;
|
---|
166 |
|
---|
167 | if (!(soaprc = soap_call___vbox__IWebsessionManager_USCOREgetSessionObject(&soap,
|
---|
168 | pcszArgEndpoint,
|
---|
169 | NULL,
|
---|
170 | &req,
|
---|
171 | &resp)))
|
---|
172 | std::cout << "session: \"" << resp.returnval << "\"\n";
|
---|
173 | }
|
---|
174 | }
|
---|
175 | else if (!strcmp(pcszMode, "logoff"))
|
---|
176 | {
|
---|
177 | if (argc < 2 + ap)
|
---|
178 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
179 | else
|
---|
180 | {
|
---|
181 | _vbox__IWebsessionManager_USCORElogoff req;
|
---|
182 | req.refIVirtualBox = argv[ap + 1];
|
---|
183 | _vbox__IWebsessionManager_USCORElogoffResponse resp;
|
---|
184 |
|
---|
185 | if (!(soaprc = soap_call___vbox__IWebsessionManager_USCORElogoff(&soap,
|
---|
186 | pcszArgEndpoint,
|
---|
187 | NULL,
|
---|
188 | &req,
|
---|
189 | &resp)))
|
---|
190 | {
|
---|
191 | ;
|
---|
192 | }
|
---|
193 | }
|
---|
194 | }
|
---|
195 | else if (!strcmp(pcszMode, "version"))
|
---|
196 | {
|
---|
197 | if (argc < 2 + ap)
|
---|
198 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
199 | else
|
---|
200 | {
|
---|
201 | _vbox__IVirtualBox_USCOREgetVersion req;
|
---|
202 | req._USCOREthis = argv[ap + 1];
|
---|
203 | _vbox__IVirtualBox_USCOREgetVersionResponse resp;
|
---|
204 |
|
---|
205 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetVersion(&soap,
|
---|
206 | pcszArgEndpoint,
|
---|
207 | NULL,
|
---|
208 | &req,
|
---|
209 | &resp)))
|
---|
210 | std::cout << "version: \"" << resp.returnval << "\"\n";
|
---|
211 | }
|
---|
212 | }
|
---|
213 | else if (!strcmp(pcszMode, "gethost"))
|
---|
214 | {
|
---|
215 | if (argc < 2 + ap)
|
---|
216 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
217 | else
|
---|
218 | {
|
---|
219 | _vbox__IVirtualBox_USCOREgetHost req;
|
---|
220 | req._USCOREthis = argv[ap + 1];
|
---|
221 | _vbox__IVirtualBox_USCOREgetHostResponse resp;
|
---|
222 |
|
---|
223 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetHost(&soap,
|
---|
224 | pcszArgEndpoint,
|
---|
225 | NULL,
|
---|
226 | &req,
|
---|
227 | &resp)))
|
---|
228 | {
|
---|
229 | std::cout << "Host objref " << resp.returnval << "\n";
|
---|
230 | }
|
---|
231 | }
|
---|
232 | }
|
---|
233 | else if (!strcmp(pcszMode, "getpc"))
|
---|
234 | {
|
---|
235 | if (argc < 2 + ap)
|
---|
236 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
237 | else
|
---|
238 | {
|
---|
239 | _vbox__IVirtualBox_USCOREgetPerformanceCollector req;
|
---|
240 | req._USCOREthis = argv[ap + 1];
|
---|
241 | _vbox__IVirtualBox_USCOREgetPerformanceCollectorResponse resp;
|
---|
242 |
|
---|
243 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetPerformanceCollector(&soap,
|
---|
244 | pcszArgEndpoint,
|
---|
245 | NULL,
|
---|
246 | &req,
|
---|
247 | &resp)))
|
---|
248 | {
|
---|
249 | std::cout << "Performance collector objref " << resp.returnval << "\n";
|
---|
250 | }
|
---|
251 | }
|
---|
252 | }
|
---|
253 | else if (!strcmp(pcszMode, "getmachines"))
|
---|
254 | {
|
---|
255 | if (argc < 2 + ap)
|
---|
256 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
257 | else
|
---|
258 | {
|
---|
259 | _vbox__IVirtualBox_USCOREgetMachines req;
|
---|
260 | req._USCOREthis = argv[ap + 1];
|
---|
261 | _vbox__IVirtualBox_USCOREgetMachinesResponse resp;
|
---|
262 |
|
---|
263 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREgetMachines(&soap,
|
---|
264 | pcszArgEndpoint,
|
---|
265 | NULL,
|
---|
266 | &req,
|
---|
267 | &resp)))
|
---|
268 | {
|
---|
269 | size_t c = resp.returnval.size();
|
---|
270 | for (size_t i = 0;
|
---|
271 | i < c;
|
---|
272 | ++i)
|
---|
273 | {
|
---|
274 | std::cout << "Machine " << i << ": objref " << resp.returnval[i] << "\n";
|
---|
275 | }
|
---|
276 | }
|
---|
277 | }
|
---|
278 | }
|
---|
279 | else if (!strcmp(pcszMode, "createmachine"))
|
---|
280 | {
|
---|
281 | if (argc < 4 + ap)
|
---|
282 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
283 | else
|
---|
284 | {
|
---|
285 | _vbox__IVirtualBox_USCOREcreateMachine req;
|
---|
286 | req._USCOREthis = argv[ap + 1];
|
---|
287 | req.settingsFile = argv[ap + 2];
|
---|
288 | req.name = argv[ap + 3];
|
---|
289 | std::cout << "createmachine: settingsFile = \"" << req.settingsFile << "\", name = \"" << req.name << "\"\n";
|
---|
290 | _vbox__IVirtualBox_USCOREcreateMachineResponse resp;
|
---|
291 |
|
---|
292 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREcreateMachine(&soap,
|
---|
293 | pcszArgEndpoint,
|
---|
294 | NULL,
|
---|
295 | &req,
|
---|
296 | &resp)))
|
---|
297 | std::cout << "Machine created: managed object reference ID is " << resp.returnval << "\n";
|
---|
298 | }
|
---|
299 | }
|
---|
300 | else if (!strcmp(pcszMode, "registermachine"))
|
---|
301 | {
|
---|
302 | if (argc < 3 + ap)
|
---|
303 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
304 | else
|
---|
305 | {
|
---|
306 | _vbox__IVirtualBox_USCOREregisterMachine req;
|
---|
307 | req._USCOREthis = argv[ap + 1];
|
---|
308 | req.machine = argv[ap + 2];
|
---|
309 | _vbox__IVirtualBox_USCOREregisterMachineResponse resp;
|
---|
310 | if (!(soaprc = soap_call___vbox__IVirtualBox_USCOREregisterMachine(&soap,
|
---|
311 | pcszArgEndpoint,
|
---|
312 | NULL,
|
---|
313 | &req,
|
---|
314 | &resp)))
|
---|
315 | std::cout << "Machine registered.\n";
|
---|
316 | }
|
---|
317 | }
|
---|
318 | else if (!strcmp(pcszMode, "getdvddrives"))
|
---|
319 | {
|
---|
320 | if (argc < 2 + ap)
|
---|
321 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
322 | else
|
---|
323 | {
|
---|
324 | _vbox__IHost_USCOREgetDVDDrives req;
|
---|
325 | req._USCOREthis = argv[ap + 1];
|
---|
326 | _vbox__IHost_USCOREgetDVDDrivesResponse resp;
|
---|
327 | if (!(soaprc = soap_call___vbox__IHost_USCOREgetDVDDrives(&soap,
|
---|
328 | pcszArgEndpoint,
|
---|
329 | NULL,
|
---|
330 | &req,
|
---|
331 | &resp)))
|
---|
332 | {
|
---|
333 | size_t c = resp.returnval.size();
|
---|
334 | for (size_t i = 0;
|
---|
335 | i < c;
|
---|
336 | ++i)
|
---|
337 | {
|
---|
338 | std::cout << "DVD drive " << i << ": objref " << resp.returnval[i] << "\n";
|
---|
339 | }
|
---|
340 | }
|
---|
341 | }
|
---|
342 | }
|
---|
343 | else if (!strcmp(pcszMode, "getname"))
|
---|
344 | {
|
---|
345 | if (argc < 2 + ap)
|
---|
346 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
347 | else
|
---|
348 | {
|
---|
349 | _vbox__IMachine_USCOREgetName req;
|
---|
350 | req._USCOREthis = argv[ap + 1];
|
---|
351 | _vbox__IMachine_USCOREgetNameResponse resp;
|
---|
352 | if (!(soaprc = soap_call___vbox__IMachine_USCOREgetName(&soap,
|
---|
353 | pcszArgEndpoint,
|
---|
354 | NULL,
|
---|
355 | &req,
|
---|
356 | &resp)))
|
---|
357 | printf("Name is: %s\n", resp.returnval.c_str());
|
---|
358 | }
|
---|
359 | }
|
---|
360 | else if (!strcmp(pcszMode, "getid"))
|
---|
361 | {
|
---|
362 | if (argc < 2 + ap)
|
---|
363 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
364 | else
|
---|
365 | {
|
---|
366 | _vbox__IMachine_USCOREgetId req;
|
---|
367 | req._USCOREthis = argv[ap + 1];
|
---|
368 | _vbox__IMachine_USCOREgetIdResponse resp;
|
---|
369 | if (!(soaprc = soap_call___vbox__IMachine_USCOREgetId(&soap,
|
---|
370 | pcszArgEndpoint,
|
---|
371 | NULL,
|
---|
372 | &req,
|
---|
373 | &resp)))
|
---|
374 | std::cout << "UUID is: " << resp.returnval << "\n";;
|
---|
375 | }
|
---|
376 | }
|
---|
377 | else if (!strcmp(pcszMode, "getostypeid"))
|
---|
378 | {
|
---|
379 | if (argc < 2 + ap)
|
---|
380 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
381 | else
|
---|
382 | {
|
---|
383 | _vbox__IMachine_USCOREgetOSTypeId req;
|
---|
384 | req._USCOREthis = argv[ap + 1];
|
---|
385 | _vbox__IMachine_USCOREgetOSTypeIdResponse resp;
|
---|
386 | if (!(soaprc = soap_call___vbox__IMachine_USCOREgetOSTypeId(&soap,
|
---|
387 | pcszArgEndpoint,
|
---|
388 | NULL,
|
---|
389 | &req,
|
---|
390 | &resp)))
|
---|
391 | std::cout << "Guest OS type is: " << resp.returnval << "\n";
|
---|
392 | }
|
---|
393 | }
|
---|
394 | else if (!strcmp(pcszMode, "savesettings"))
|
---|
395 | {
|
---|
396 | if (argc < 2 + ap)
|
---|
397 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
398 | else
|
---|
399 | {
|
---|
400 | _vbox__IMachine_USCOREsaveSettings req;
|
---|
401 | req._USCOREthis = argv[ap + 1];
|
---|
402 | _vbox__IMachine_USCOREsaveSettingsResponse resp;
|
---|
403 | if (!(soaprc = soap_call___vbox__IMachine_USCOREsaveSettings(&soap,
|
---|
404 | pcszArgEndpoint,
|
---|
405 | NULL,
|
---|
406 | &req,
|
---|
407 | &resp)))
|
---|
408 | std::cout << "Settings saved\n";
|
---|
409 | }
|
---|
410 | }
|
---|
411 | else if (!strcmp(pcszMode, "setupmetrics"))
|
---|
412 | {
|
---|
413 | if (argc < 2 + ap)
|
---|
414 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
415 | else
|
---|
416 | {
|
---|
417 | _vbox__IPerformanceCollector_USCOREsetupMetrics req;
|
---|
418 | req._USCOREthis = argv[ap + 1];
|
---|
419 | // req.metricNames[0] = "*";
|
---|
420 | // req.objects
|
---|
421 | req.period = 1; // seconds
|
---|
422 | req.count = 100;
|
---|
423 | _vbox__IPerformanceCollector_USCOREsetupMetricsResponse resp;
|
---|
424 | if (!(soaprc = soap_call___vbox__IPerformanceCollector_USCOREsetupMetrics(&soap,
|
---|
425 | pcszArgEndpoint,
|
---|
426 | NULL,
|
---|
427 | &req,
|
---|
428 | &resp)))
|
---|
429 | {
|
---|
430 | size_t c = resp.returnval.size();
|
---|
431 | for (size_t i = 0;
|
---|
432 | i < c;
|
---|
433 | ++i)
|
---|
434 | {
|
---|
435 | std::cout << "Metric " << i << ": objref " << resp.returnval[i] << "\n";
|
---|
436 | }
|
---|
437 | }
|
---|
438 | }
|
---|
439 | }
|
---|
440 | else if (!strcmp(pcszMode, "querymetricsdata"))
|
---|
441 | {
|
---|
442 | if (argc < 2 + ap)
|
---|
443 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
444 | else
|
---|
445 | {
|
---|
446 | _vbox__IPerformanceCollector_USCOREqueryMetricsData req;
|
---|
447 | req._USCOREthis = argv[ap + 1];
|
---|
448 | // req.metricNames[0] = "*";
|
---|
449 | // req.objects
|
---|
450 | _vbox__IPerformanceCollector_USCOREqueryMetricsDataResponse resp;
|
---|
451 | if (!(soaprc = soap_call___vbox__IPerformanceCollector_USCOREqueryMetricsData(&soap,
|
---|
452 | pcszArgEndpoint,
|
---|
453 | NULL,
|
---|
454 | &req,
|
---|
455 | &resp)))
|
---|
456 | {
|
---|
457 | size_t c = resp.returnval.size();
|
---|
458 | for (size_t i = 0;
|
---|
459 | i < c;
|
---|
460 | ++i)
|
---|
461 | {
|
---|
462 | std::cout << "long " << i << ": " << resp.returnval[i] << "\n";
|
---|
463 | }
|
---|
464 | }
|
---|
465 | }
|
---|
466 | }
|
---|
467 | else if (!strcmp(pcszMode, "errorinfo"))
|
---|
468 | {
|
---|
469 | if (argc < 2 + ap)
|
---|
470 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
471 | else
|
---|
472 | {
|
---|
473 | _vbox__IVirtualBoxErrorInfo_USCOREgetResultCode req;
|
---|
474 | req._USCOREthis = argv[ap + 1];
|
---|
475 | _vbox__IVirtualBoxErrorInfo_USCOREgetResultCodeResponse resp;
|
---|
476 | if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetResultCode(&soap,
|
---|
477 | pcszArgEndpoint,
|
---|
478 | NULL,
|
---|
479 | &req,
|
---|
480 | &resp)))
|
---|
481 | {
|
---|
482 | std::cout << "ErrorInfo ResultCode: " << std::hex << resp.returnval << "\n";
|
---|
483 |
|
---|
484 | _vbox__IVirtualBoxErrorInfo_USCOREgetText req2;
|
---|
485 | req2._USCOREthis = argv[ap + 1];
|
---|
486 | _vbox__IVirtualBoxErrorInfo_USCOREgetTextResponse resp2;
|
---|
487 | if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetText(&soap,
|
---|
488 | pcszArgEndpoint,
|
---|
489 | NULL,
|
---|
490 | &req2,
|
---|
491 | &resp2)))
|
---|
492 | {
|
---|
493 | std::cout << "ErrorInfo Text: " << resp2.returnval << "\n";
|
---|
494 |
|
---|
495 | _vbox__IVirtualBoxErrorInfo_USCOREgetNext req3;
|
---|
496 | req3._USCOREthis = argv[ap + 1];
|
---|
497 | _vbox__IVirtualBoxErrorInfo_USCOREgetNextResponse resp3;
|
---|
498 | if (!(soaprc = soap_call___vbox__IVirtualBoxErrorInfo_USCOREgetNext(&soap,
|
---|
499 | pcszArgEndpoint,
|
---|
500 | NULL,
|
---|
501 | &req3,
|
---|
502 | &resp3)))
|
---|
503 | std::cout << "Next ErrorInfo: " << resp3.returnval << "\n";
|
---|
504 | }
|
---|
505 | }
|
---|
506 | }
|
---|
507 | }
|
---|
508 | else if (!strcmp(pcszMode, "release"))
|
---|
509 | {
|
---|
510 | if (argc < 2 + ap)
|
---|
511 | std::cout << "Not enough arguments for \"" << pcszMode << "\" mode.\n";
|
---|
512 | else
|
---|
513 | {
|
---|
514 | _vbox__IManagedObjectRef_USCORErelease req;
|
---|
515 | req._USCOREthis = argv[ap + 1];
|
---|
516 | _vbox__IManagedObjectRef_USCOREreleaseResponse resp;
|
---|
517 | if (!(soaprc = soap_call___vbox__IManagedObjectRef_USCORErelease(&soap,
|
---|
518 | pcszArgEndpoint,
|
---|
519 | NULL,
|
---|
520 | &req,
|
---|
521 | &resp)))
|
---|
522 | std::cout << "Managed object reference " << req._USCOREthis << " released.\n";
|
---|
523 | }
|
---|
524 | }
|
---|
525 | else
|
---|
526 | std::cout << "Unknown mode parameter \"" << pcszMode << "\".\n";
|
---|
527 |
|
---|
528 | if (soaprc)
|
---|
529 | {
|
---|
530 | if ( (soap.fault)
|
---|
531 | && (soap.fault->detail)
|
---|
532 | )
|
---|
533 | {
|
---|
534 | // generic fault message whether the fault is known or not
|
---|
535 | std::cerr << "Generic fault message:\n";
|
---|
536 | soap_print_fault(&soap, stderr); // display the SOAP fault message on the stderr stream
|
---|
537 |
|
---|
538 | if (soap.fault->detail->vbox__InvalidObjectFault)
|
---|
539 | {
|
---|
540 | std::cerr << "Bad object ID: " << soap.fault->detail->vbox__InvalidObjectFault->badObjectID << "\n";
|
---|
541 | }
|
---|
542 | else if (soap.fault->detail->vbox__RuntimeFault)
|
---|
543 | {
|
---|
544 | std::cerr << "Result code: 0x" << std::hex << soap.fault->detail->vbox__RuntimeFault->resultCode << "\n";
|
---|
545 | std::cerr << "ErrorInfo: " << soap.fault->detail->vbox__RuntimeFault->returnval << "\n";
|
---|
546 | }
|
---|
547 | }
|
---|
548 | else
|
---|
549 | {
|
---|
550 | std::cerr << "Invalid fault data, fault message:\n";
|
---|
551 | soap_print_fault(&soap, stderr); // display the SOAP fault message on the stderr stream
|
---|
552 | }
|
---|
553 | }
|
---|
554 |
|
---|
555 | soap_destroy(&soap); // delete deserialized class instances (for C++ only)
|
---|
556 | soap_end(&soap); // remove deserialized data and clean up
|
---|
557 | soap_done(&soap); // detach the gSOAP environment
|
---|
558 |
|
---|
559 | return soaprc;
|
---|
560 | }
|
---|
561 |
|
---|