SOAPpy.Types.faultType: Cannot use object of type stdClass as array

Tamer Higazi th982a at googlemail.com
Sat Mar 23 20:38:41 CET 2013


Chris!
I did what you said before in several ways.

The last way was putting the user and password directly into the dict as
parameter ALWAYS ends up telling me, that I cannot use object of
standard type class as ARRAY....

I did it this time with suds. So packaging issue is now out of scope,
and always the same headache.


now tell me what this error might tell me:


suds.WebFault: Server raised fault: 'Cannot use object of type stdClass
as array'
File "/storage/PyProjects/toolsAPP/python/KASUpdate2.py", line 23, in
<module>
  KasObj = KASSystem()
File "/storage/PyProjects/toolsAPP/python/KASUpdate2.py", line 20, in
__init__
  'SessionUpdateLifeTime':'Y'})
File
"/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py",
line 542, in __call__
File
"/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py",
line 602, in invoke
File
"/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py",
line 649, in send
File
"/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/client.py",
line 702, in failed
File
"/storage/PyENV/lin/toolsENV/lib/python2.7/site-packages/suds-0.4-py2.7.egg/suds/bindings/binding.py",
line 265, in get_fault


and when I open the python files they hand me out only the error
messages, which was sent back from Server!

here is the code:

import hashlib
from suds.client import Client
from suds import WebFault

class KASSystem:
    def __init__(self):
        WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl'
        WSDL_API = 'https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl'

        m = hashlib.sha1()
        m.update('userpass')

        SoapClient = Client(WSDL_AUTH)

        SoapClient.service.KasAuth({
            'KasUser':'userlogin',
            'KasAuthType':'sha1',
            'KasPassword':m.hexdigest(),
            'SessionLifeTime':1800,
            'SessionUpdateLifeTime':'Y'})


KasObj = KASSystem()



Tamer

Am 23.03.2013 16:03, schrieb Chris Angelico:
> 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