Posted: Wed Aug 13, 2008 4:51 pm Post subject: HOWTO: Using GC's webservice from Python
Being a novice with SOAP, I had a bit of a job with accessing the Gamecreate
web interface from Python. However, after figuring out the problem/bug, it is
a very elegant way of working with GC from Python scripts, e.g. for checking
host and server status. I thought I would share the solution with you in case
anyone else wishes to use Python for the webservice.
If you try to access one of the methods, you are most likely going to get a
failed response like this:
>>> statusList = service.GetHostStatusList(actorUsername='YOURUSERNAME',actorPassword='YOURPASSWORD',domainId=YOURDOMAINID)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/site-packages/SOAPpy/Client.py", line 470, in __call__
return self.__r_call(*args, **kw)
File "/usr/lib/python2.4/site-packages/SOAPpy/Client.py", line 492, in __r_call
File "/usr/lib/python2.4/site-packages/SOAPpy/Client.py", line 406, in __call
SOAPpy.Types.faultType: <Fault soap:Server: Argument 2 is not valid in SqlBuilder>
After inspection of the HTTP-text that was transmitted, and comparing with
a working PHP example, I found that the trick to making this work was to
add the following two lines after the creation of the proxy object:
Id = 2332
Name = "Beatrice"
Address = "X.X.X.X"
Status = "Online"
OperSystem = "Linux"
ServerCount = 1
CPU = 5.5
Memory = 906556
Disk = 21660
Online = True
The output is a bit cleaner than before, data types are reasonable, there is no need for the property settings, suds is better maintained than SOAPpy, and suds can be used in Twisted, if that's your preferred framework.
I did some tests with ZSI as well, but it was a pain to use, especially with Twisted. suds just works.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum