SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Chris Angelico
rosuav at gmail.com
Sat Mar 23 11:03:57 EDT 2013
On Sun, Mar 24, 2013 at 12:33 AM, Tamer Higazi <th982a at googlemail.com> wrote:
> Hi Chris!
> thanks.... But I am about of going nuts.... I did everything according
> their sample:
>
> http://kasapi.kasserver.com/dokumentation/?open=soap
Since I'm not fluent in German, I'm relying on Google Translate to
read of that page. (I didn't find an obvious English version of the
page, but maybe I just didn't look in the right place.)
One thing I've found about the PHP SOAP library is that it seems to
behave quite oddly in some circumstances - my suspicion is the WSDL
file (eg when it's unable to load it). Try monitoring the actual
traffic - SOAP is XML carried over HTTP, so you should be able to just
snoop the TCP/IP socket (easiest way might be to switch in your own
server). See if you can spot a difference between the request that PHP
sends and the one your Python script sends. Fortunately you're not
moving megabytes of data around, here - it should be easy enough to
eyeball the requests and see what's different about them :)
A tip, by the way:
userpass = ['login','password']
m = hashlib.sha1()
m.update(userpass[1])
userpass[1] = m.hexdigest()
loginData = {'user':userpass[0],'pass':userpass[1]}
'KasUser':loginData['user'],
'KasPassword':loginData['pass'],
You keep packaging and repackaging the credentials. I'm assuming you
won't actually have them hard-coded like that (if you do, I would
recommend hard-coding the SHA1 hash, rather than the password itself),
so I'll stick with the userpass list (or tuple, which would work
exactly the same way).
password = hashlib.sha1(userpass[1]).hexdigest()
...
'KasUser':userpass[0],
'KasPassword':password,
Or even inline that completely (which is what I'd probably do).
There's no need to stuff it into a dictionary, only to pull it out
again.
Also: A try/except that just prints out the error message usually
isn't helpful. Save yourself the trouble, at least during initial
testing - just let the exception terminate your script. You'll get all
the same information, plus the full traceback, and it's cost you
exactly zero development time :) Later on, you can add try/except if
you need to do something other than terminate, but often that "later
on" never even happens.
ChrisA
More information about the Python-list
mailing list