Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41736 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2013-03-24 02:03 +1100
Last post2013-03-24 02:03 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array Chris Angelico <rosuav@gmail.com> - 2013-03-24 02:03 +1100

#41736 — Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array

FromChris Angelico <rosuav@gmail.com>
Date2013-03-24 02:03 +1100
SubjectRe: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Message-ID<mailman.3639.1364051041.2939.python-list@python.org>
On Sun, Mar 24, 2013 at 12:33 AM, Tamer Higazi <th982a@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web