VirtualBox

Ticket #12775: test_vboxwebsrv.php

File test_vboxwebsrv.php, 2.7 KB (added by Chris Brown, 10 years ago)

php test case

Line 
1<!DOCTYPE html>
2<html>
3 <head>
4 <meta charset='utf-8' />
5 <meta http-equiv="X-UA-Compatible" content="chrome=1" />
6 <title>test vboxwebsrv</title>
7 </head>
8
9 <body>
10 <p> testing vboxwebsrv... </p>
11
12 <?php
13 require_once('lib/vboxServiceWrappers.php');
14 require_once('lib/utils.php');
15
16 $hostonline = false;
17 $hosturl = "http://127.0.0.1:18083/";
18 while (!$foobar) {
19
20 try {
21
22 //Connect to webservice
23 $connection = new SoapClient("lib/vboxwebService.wsdl", array('location' => $hosturl));
24
25 //Logon to webservice
26 $websessionManager = new IWebsessionManager($connection);
27 echo ' <p> Connected... </p> ';
28 } catch (Exception $ex) {
29 echo $ex->getMessage();
30 }
31
32 try {
33 // Auththenticate with the webservice
34 echo '<p> Attempting logon... </p>';
35 // If vboxwebsrv borks it will hang here
36 // If this happens refresh the page and vboxwebsrv will crash
37 $vbox = $websessionManager->logon("username", "password");
38 echo '<p> Authenticated... </p>';
39 } catch (Exception $ex) {
40 echo $ex->getMessage();
41 }
42
43
44 $hostonline = true;
45 if ($hostonline) {
46
47 // Get the installed version of VirtualBox on the host
48 $data = $vbox->version . "-" . $vbox->revision;
49 echo '<p> VirtualBox Version: ' . $data . '</p>';
50
51 // Get the host Operating System
52 $vboxhost = $vbox->host;
53 $data = $vboxhost->operatingSystem;
54 echo '<p> Operating System: ' . $data . '</p>';
55
56 // Get the host Operating System Version
57 $data = $vboxhost->OSVersion;
58 echo '<p> Operating System Version: ' . $data . '</p>';
59
60 // Log out of the webservice
61 try {
62 echo '<p> Attempting Logout...</p>';
63 $websessionManager->logoff($vbox->handle);
64 echo '<p> Logged out... </p>';
65 } catch (Exception $ex) {
66 echo $ex->getMessage();
67 }
68 }
69 else {
70 echo '<p> Could not connect to vboxwebsrv </p>';
71 }
72 }
73 ?>
74 </body>
75</html>

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