James,

thanks for pointing this out. It appears that SOAP::Lite has changed since the documentation was written.

From your notes I gather that you ran stubmaker on the vboxwebService.wsdl file, not the vboxweb.wsdl file. As you're probably aware, the latter includes the former.

Now, stubmaker gets confused with namespaces when running it on the service file and injects "http://www.virtualbox.org/Service"; into each method generated in the vboxService.pm when the namespace should be "http://www.virtualbox.org/"; (without the "Service").

This is why the documentation says you should run stubmaker on vboxweb.wsdl, bypassing the service file, and avoiding the namespace confusion. At the time I didn't research the problem in detail since this workaround solved it for the time being.

It appears however that stubmaker now behaves differently. With SOAP::Lite 0.69 on Gentoo here, it no longer generates a vboxService.pm file, but a "FakeService.pm" file which doesn't work.

I have found the following workaround: run stubmaker on vboxwebService.wsdl and then, in the resulting vboxService.pm file, manually replace all occurences of "http://www.virtualbox.org/Service"; with "http://www.virtualbox.org/";. After that, the clienttest.pl runs fine -- except for one other problem with an API change, which is why I have attached a new version. This will be fixed in the next SDK release.

If there's somebody reading this who is aware of that we're doing something wrong with the namespaces in our WSDL files, we're open for feedback. But since all languages handle our files fine except for SOAP::Lite, I am suspecting that the problem lies not with us. I'm happy to fix the perl code and/or documentation so long as it doesn't break the other bindings.

Ulrich


James Lucas wrote:
Has anyone else encountered this? I am still having issues using the SDK.

- James

James Lucas wrote:
Frank suggested I moved some of my Virtual Box management scripts to using the
API instead of using VBoxManage for querying information about individual
machines. I've followed all of the documentation (including generating the
vboxService.pm file) in the SDK however I have the following issue.

When running the perl clienttest.pl file provided by the SDK the vboxwebsrv
throws a error "SOAP FAULT: Method 'namesp1:IWebsessionManager_logon' not
implemented: method name or namespace not recognized [SOAP-ENV:Client]"

Web service authentication is set to null for testing. Using the distribution
provided program 'webtest' I know that the vboxwebsrv is working.
Has anyone encountered this? If anyone has the perl clienttest working can you
please let me know if the SOAP generated is different from what I have below.
(SOAP requests can be dumped using [ use SOAP::Lite +trace => 'debug'; ] in
clienttest.

The SOAP generated is:

[r...@artemis1 samples]# ./clienttest.pl SOAP::Transport::HTTP::Client::send_receive: POST http://localhost:18083/
HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 649
Content-Type: text/xml; charset=utf-8
SOAPAction: ""

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope
xmlns:namesp1="http://www.virtualbox.org/Service";
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:interface="urn:vbox" xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:vbox="http://www.virtualbox.org/";><soap:Body><namesp1:IWebsessionManager_logon><username
xsi:type="xsd:string">test</username><password
xsi:type="xsd:string">test</password></namesp1:IWebsessionManager_logon></soap:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error
Connection: close
Server: gSOAP/2.7
Content-Length: 629
Content-Type: text/xml; charset=utf-8
Client-Date: Sat, 20 Dec 2008 23:42:23 GMT
Client-Peer: 127.0.0.1:18083
Client-Response-Num: 1

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:vbox="http://www.virtualbox.org/";><SOAP-ENV:Body
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Method
'namesp1:IWebsessionManager_logon' not implemented: method name or namespace
not
recognized</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
[clienttest] Logon to session manager with user "test" and password "test"
failed.
Stopped at ./clienttest.pl line 79.



#!/usr/bin/perl

#
# This little perl program attempts to connect to a running VirtualBox
# webservice and calls various methods on it. Please refer to the SDK
# programming reference (SDKRef.pdf) for how to use this sample.
#
# Copyright (C) 2006-2009 Sun Microsystems, Inc.
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# 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.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
# Clara, CA 95054 USA or visit http://www.sun.com if you need
# additional information or have any questions.
#

use strict;
use SOAP::Lite;
use vboxService;    # generated by stubmaker, see SDKRef.pdf
use Data::Dumper;

my $cmd = 'clienttest';
my $optMode;
my $vmname;

while (my $this = shift(@ARGV))
{
    if (($this =~ /^-h/) || ($this =~ /^--help/))
    {
        print "$cmd: test the VirtualBox web service.\n".
              "Usage:\n".
              "    $cmd <mode>\n".
              "with <mode> being one of 'version', 'list', 'start'; default is 'list'.\n".
              "    $cmd version: print version of VirtualBox web service.\n".
              "    $cmd list: list installed virtual machines.\n".
              "    $cmd startvm <vm>: start the virtual machine named <vm>.\n";
        exit 0;
    }
    elsif (    ($this eq 'version')
            || ($this eq 'list')
          )
    {
        $optMode = $this;
    }
    elsif ($this eq 'startvm')
    {
        $optMode = $this;

        if (!($vmname = shift(@ARGV)))
        {
            die "[$cmd] Missing parameter: You must specify the name of the VM to start.\nStopped";
        }
    }
    else
    {
        die "[$cmd] Unknown option \"$this\"; stopped";
    }
}

$optMode = "list"
    if (!$optMode);

my $vbox = vboxService->IWebsessionManager_logon("test", "test");

if (!$vbox)
{
    die "[$cmd] Logon to session manager with user \"test\" and password \"test\" failed.\nStopped";
}

if ($optMode eq "version")
{
    my $v = vboxService->IVirtualBox_getVersion($vbox);
    print "[$cmd] Version number of running VirtualBox web service: $v\n";
}
elsif ($optMode eq "list")
{
    print "[$cmd] Listing machines:\n";
    my @result = vboxService->IVirtualBox_getMachines2($vbox);
    foreach my $idMachine (@result)
    {
        my $if = vboxService->IManagedObjectRef_getInterfaceName($idMachine);
        my $name = vboxService->IMachine_getName($idMachine);

        print "machine $if $idMachine: $name\n";
    }
}
elsif ($optMode eq "startvm")
{
    # assume it's a UUID
    my $machine = vboxService->IVirtualBox_getMachine($vbox, $vmname);
    if (!$machine)
    {
        # no: then try a name
        $machine = vboxService->IVirtualBox_findMachine($vbox, $vmname);
    }

    die "[$cmd] Cannot find VM \"$vmname\"; stopped"
        if (!$machine);

    my $session = vboxService->IWebsessionManager_getSessionObject($vbox);
    die "[$cmd] Cannot get session object; stopped"
        if (!$session);

    my $uuid = vboxService->IMachine_getId($machine);
    die "[$cmd] Cannot get uuid for machine; stopped"
        if (!$uuid);

    print "[$cmd] UUID: $uuid\n";

    my $progress = vboxService->IVirtualBox_openRemoteSession($vbox,
                                                              $session,
                                                              $uuid,
                                                              "vrdp",
                                                              "");
    die "[$cmd] Cannot open remote session; stopped"
        if (!$progress);

    print("[$cmd] Waiting for the remote session to open...\n");
    vboxService->IProgress_waitForCompletion($progress, -1);

    my $fCompleted;
    $fCompleted = vboxService->IProgress_getCompleted($progress);
    print("[$cmd] Completed: $fCompleted\n");

    my $resultCode;
    $resultCode = vboxService->IProgress_getResultCode($progress);

    print("[$cmd] Result: $resultCode\n");

    vboxService->ISession_close($session);

    vboxService->IWebsessionManager_logoff($vbox);
}
_______________________________________________
vbox-dev mailing list
[email protected]
http://vbox.innotek.de/mailman/listinfo/vbox-dev

Reply via email to