[Fedora-suds-list] Accessing VirtualBox SOAP API using suds

Maciej Grela maciej.grela at gmail.com
Wed Aug 29 22:53:31 UTC 2012


Hi,

I've been trying to develop a fencing agent for VirtualBox SOAP API
(vboxwebsrv service) using the suds package and I've ran into a couple
of issues on which I need some clarification and/or suggestions. At
first, I've tried to use the following code:

grela at kraken ~/Dokumenty/devel/fence_vbox $ cat vbox_test
#!/usr/bin/python2

import suds
import logging
from logging.handlers import SysLogHandler

logging.basicConfig(level=logging.INFO)

conn = suds.client.Client("http://localhost:18083/?wsdl")

vbox_ref = conn.service.IWebsessionManager_logon(username='', password='')
print("Login created VirtualBox ref: %s" % (vbox_ref))

conn.service.IWebsessionManager_logoff(vbox_ref)
grela at kraken ~/Dokumenty/devel/fence_vbox $ ./vbox_test
Traceback (most recent call last):
  File "./vbox_test", line 11, in <module>
    vbox_ref = conn.service.IWebsessionManager_logon(username='', password='')
  File "/usr/lib64/python2.7/site-packages/suds/client.py", line 296,
in __getattr__
    port = self.__find(0)
  File "/usr/lib64/python2.7/site-packages/suds/client.py", line 331, in __find
    raise Exception, 'No services defined'
Exception: No services defined
grela at kraken ~/Dokumenty/devel/fence_vbox $

According to result of https://www.virtualbox.org/ticket/8687
VirtualBox should have been fixed to properly returned a WSDL
describing it's service when requested. Unfortunately, as you can see
the code fails because of no services. Examining the XML content
returned from http://localhost:18083/?wsdl reveals, that it contains
only the schema for the operations, messages and types without any
<service> tags. I think this is in violation of the spec, am I right ?

Looking around further in the VirtualBox SDK I discovered, that there
are 2 WSDL files there (/usr/lib/virtualbox/sdk/bindings/webservice):
vboxweb.wsdl (the one that vboxwebsrv returns as content of URL
http://localhost:18083/?wsdl) and vboxwebService.wsdl which looks more
promising:

<?xml version="1.0" encoding="utf-8"?>
<!--
  DO NOT EDIT! This is a generated file.
  Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's
generic pseudo-IDL file)
  Generator: src/VBox/Main/webservice/websrv-wsdl-service.xsl
-->
<definitions xmlns:interface="urn:vbox"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:vbox="http://www.virtualbox.org/"
xmlns="http://schemas.xmlsoap.org/wsdl/" name="VirtualBox"
targetNamespace="http://www.virtualbox.org/Service">
  <import location="vboxweb.wsdl" namespace="http://www.virtualbox.org/"/>
  <service name="vboxService">
    <port binding="vbox:vboxBinding" name="vboxServicePort">
      <soap:address location="http://localhost:18083/"/>
    </port>
  </service>
</definitions>

It seems to me, that vboxwebsrv should return this file and respond to
http://localhost:18083/vboxweb.wsdl with the WSDL data schema. To
check this, I took those two files and put them on a local apache
instance, changed the code a bit and confirmed that this approach
works:

grela at kraken ~/Dokumenty/devel/fence_vbox $ cat ./vbox_test_local_wsdl
#!/usr/bin/python2

import suds
import logging
from logging.handlers import SysLogHandler

logging.basicConfig(level=logging.INFO)

conn = suds.client.Client("http://localhost/redhat/vboxwebService.wsdl")

vbox_ref = conn.service.IWebsessionManager_logon(username='', password='')
print("Login created VirtualBox ref: %s" % (vbox_ref))

conn.service.IWebsessionManager_logoff(vbox_ref)
grela at kraken ~/Dokumenty/devel/fence_vbox $ ./vbox_test_local_wsdl
Login created VirtualBox ref: 0f2ca4e7cb9a4e83-000000000000000a
grela at kraken ~/Dokumenty/devel/fence_vbox $

This output looked much better and I became more convinced, that
vboxwebsrv is serving the wrong file. I would like to know, am I
thinking along proper lines ? I'm not that big of a SOAP expert and a
confirmation would be useful before I start asking VirtualBox to
change their behaviour.

Second problem I discovered was with parameter names containing '_'
characters. They are silently swallowed by the suds code forbidding
any code from running. Unfortunately, every VirtualBox SOAP API call
has a parameter called '_this' :/. This issue was already described by
someone so I just added a 'me too' comment there:
https://fedorahosted.org/suds/ticket/330

Is the fix proposed there valid ? If yes, is there any chance it will
be applied ?

Thanks for your help in advance.

Best regards,
Maciej Grela


More information about the suds mailing list