Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Hi Chris! The example from the website is buggy because the WSDL urls are not correct... $WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl' $WSDL_API ='https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl' which I had replaced so far. then you will see the results, even if the login and pass do not match. I think for many python developers it might be really interesting to know, WHAT A PHP ARRAY is in python in a SOAP environment. Tamer Am 23.03.2013 21:55, schrieb Chris Angelico: On Sun, Mar 24, 2013 at 6:38 AM, Tamer Higazi th9...@googlemail.com wrote: 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' So it's the same error this way, too. That error came back from the server, and is being quoted verbatim. That means that, ultimately, the problem is in the XML blob that you're sending it; the trick is to figure out what exactly the server isn't happy with. (Aside: The server is at least partly at fault here. It should be giving more useful error messages. But I'm assuming you don't have any control over the server.) I tried the reference PHP implementation off the web site, and it's coming back with 500 Internal Server Error with body of text/html, which is clearly buggy documentation. When I change it to use the WSDL you're using, I can actually get something plausible out of it. Modified PHP code: ?php // URIs zu den WSDL-Dateien $WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl'; //$WSDL_API = 'https://kasserver.com/schnittstelle/soap/wsdl/KasApi.wsdl'; // Logindaten $kas_user = 'w001234'; // KAS-Logon $kas_pass = 'xxx'; // KAS-Passwort $session_lifetime = 1800; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung $session_update_lifetime = 'Y'; // Soll bei jeder Aktion die Sessionlifetime wieder auf den // Wert in $session_lifetime gesetzt werden? ('Y' / 'N') try { $SoapLogon = new SoapClient($WSDL_AUTH,[trace=1]); // url zur wsdl - Datei $CredentialToken = $SoapLogon-KasAuth( array('KasUser' = $kas_user, 'KasAuthType' = 'sha1', 'KasPassword' = sha1($kas_pass), 'SessionLifeTime' = $session_lifetime, 'SessionUpdateLifeTime' = $session_update_lifetime ) ); } // Fehler abfangen und ausgeben catch (SoapFault $fault) { echo Request:\n.$SoapLogon-__getLastRequestHeaders().\n.$SoapLogon-__getLastRequest().\n; echo Response:\n.$SoapLogon-__getLastResponseHeaders().\n.$SoapLogon-__getLastResponse().\n; trigger_error(Fehlernummer: {$fault-faultcode}, Fehlermeldung: {$fault-faultstring}, Verursacher: {$fault-faultactor}, Details: {$fault-detail}, E_USER_ERROR); } (Another aside: Until I added the two echo lines, this had a try/catch that simply triggered a fatal error. This is pointless. Just let the error happen!) Here's the packet the PHP code sends: ?xml version=1.0 encoding=UTF-8? SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/; xmlns:ns1=urn:xmethodsKasApiAuthentication xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:ns2=http://xml.apache.org/xml-soap; xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/; SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/;SOAP-ENV:Bodyns1:KasAuthParams xsi:type=ns2:Mapitemkey xsi:type=xsd:stringKasUser/keyvalue xsi:type=xsd:stringw001234/value/itemitemkey xsi:type=xsd:stringKasAuthType/keyvalue xsi:type=xsd:stringsha1/value/itemitemkey xsi:type=xsd:stringKasPassword/keyvalue xsi:type=xsd:string2db6d21d365f544f7ca3bcfb443ac96898a7a069/value/itemitemkey xsi:type=xsd:stringSessionLifeTime/keyvalue xsi:type=xsd:int1800/value/itemitemkey xsi:type=xsd:stringSessionUpdateLifeTime/keyvalue xsi:type=xsd:stringY/value/item/Params/ns1:KasAuth/SOAP-ENV:Body/SOAP-ENV:Envelope Here's what your original Python version sends, lifted via tcpdump as I'm not sufficiently familiar with soappy to get a full packet dump out of it: ?xml version=1.0 encoding=UTF-8? SOAP-ENV:Envelope SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/; xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance;
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Hi Chris! thanks But I am about of going nuts I did everything according their sample: http://kasapi.kasserver.com/dokumentation/?open=soap and wanted to accomplish it in python! If I pass a dict, I get the error telling me, this nonsense. What should I do?! I even tried it in suds instead of soappy, and I am not getting further. Tamer Am 21.03.2013 17:21, schrieb Chris Angelico: On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi th9...@googlemail.com wrote: SOAPpy.Types.faultType: Fault SOAP-ENV:Server: Cannot use object of type stdClass as array stdClass looks like a PHP error. Check out the server's requirements; perhaps you need to provide something as a list that you're providing as a dict, or something. I'd look at that loginData, for instance. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On 03/23/2013 09:33 AM, Tamer Higazi wrote: Hi Chris! thanks But I am about of going nuts I did everything according their sample: http://kasapi.kasserver.com/dokumentation/?open=soap and wanted to accomplish it in python! Isn't there an API on Python SOAPpy published somewhere? Wild guess, but perhaps the 1800 should have been '1800' php blurs the distinction between numbers and strings, and maybe the dict values are supposed to be all strings. If I pass a dict, I get the error telling me, this nonsense. What should I do?! I even tried it in suds instead of soappy, and I am not getting further. Tamer Am 21.03.2013 17:21, schrieb Chris Angelico: On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi th9...@googlemail.com wrote: SOAPpy.Types.faultType: Fault SOAP-ENV:Server: Cannot use object of type stdClass as array stdClass looks like a PHP error. Check out the server's requirements; perhaps you need to provide something as a list that you're providing as a dict, or something. I'd look at that loginData, for instance. ChrisA -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On Sun, Mar 24, 2013 at 12:33 AM, Tamer Higazi th9...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
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 th9...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On Sun, Mar 24, 2013 at 6:38 AM, Tamer Higazi th9...@googlemail.com wrote: 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' So it's the same error this way, too. That error came back from the server, and is being quoted verbatim. That means that, ultimately, the problem is in the XML blob that you're sending it; the trick is to figure out what exactly the server isn't happy with. (Aside: The server is at least partly at fault here. It should be giving more useful error messages. But I'm assuming you don't have any control over the server.) I tried the reference PHP implementation off the web site, and it's coming back with 500 Internal Server Error with body of text/html, which is clearly buggy documentation. When I change it to use the WSDL you're using, I can actually get something plausible out of it. Modified PHP code: ?php // URIs zu den WSDL-Dateien $WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl'; //$WSDL_API = 'https://kasserver.com/schnittstelle/soap/wsdl/KasApi.wsdl'; // Logindaten $kas_user = 'w001234'; // KAS-Logon $kas_pass = 'xxx'; // KAS-Passwort $session_lifetime = 1800; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung $session_update_lifetime = 'Y'; // Soll bei jeder Aktion die Sessionlifetime wieder auf den // Wert in $session_lifetime gesetzt werden? ('Y' / 'N') try { $SoapLogon = new SoapClient($WSDL_AUTH,[trace=1]); // url zur wsdl - Datei $CredentialToken = $SoapLogon-KasAuth( array('KasUser' = $kas_user, 'KasAuthType' = 'sha1', 'KasPassword' = sha1($kas_pass), 'SessionLifeTime' = $session_lifetime, 'SessionUpdateLifeTime' = $session_update_lifetime ) ); } // Fehler abfangen und ausgeben catch (SoapFault $fault) { echo Request:\n.$SoapLogon-__getLastRequestHeaders().\n.$SoapLogon-__getLastRequest().\n; echo Response:\n.$SoapLogon-__getLastResponseHeaders().\n.$SoapLogon-__getLastResponse().\n; trigger_error(Fehlernummer: {$fault-faultcode}, Fehlermeldung: {$fault-faultstring}, Verursacher: {$fault-faultactor}, Details: {$fault-detail}, E_USER_ERROR); } (Another aside: Until I added the two echo lines, this had a try/catch that simply triggered a fatal error. This is pointless. Just let the error happen!) Here's the packet the PHP code sends: ?xml version=1.0 encoding=UTF-8? SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/; xmlns:ns1=urn:xmethodsKasApiAuthentication xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:xsd=http://www.w3.org/2001/XMLSchema; xmlns:ns2=http://xml.apache.org/xml-soap; xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/; SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/;SOAP-ENV:Bodyns1:KasAuthParams xsi:type=ns2:Mapitemkey xsi:type=xsd:stringKasUser/keyvalue xsi:type=xsd:stringw001234/value/itemitemkey xsi:type=xsd:stringKasAuthType/keyvalue xsi:type=xsd:stringsha1/value/itemitemkey xsi:type=xsd:stringKasPassword/keyvalue xsi:type=xsd:string2db6d21d365f544f7ca3bcfb443ac96898a7a069/value/itemitemkey xsi:type=xsd:stringSessionLifeTime/keyvalue xsi:type=xsd:int1800/value/itemitemkey xsi:type=xsd:stringSessionUpdateLifeTime/keyvalue xsi:type=xsd:stringY/value/item/Params/ns1:KasAuth/SOAP-ENV:Body/SOAP-ENV:Envelope Here's what your original Python version sends, lifted via tcpdump as I'm not sufficiently familiar with soappy to get a full packet dump out of it: ?xml version=1.0 encoding=UTF-8? SOAP-ENV:Envelope SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/; xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/; xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance; xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/; xmlns:xsd=http://www.w3.org/1999/XMLSchema; SOAP-ENV:Body ns1:KasAuth xmlns:ns1=urn:xmethodsKasApiAuthentication SOAP-ENC:root=1 v1 SessionUpdateLifeTime xsi:type=xsd:stringY/SessionUpdateLifeTime KasAuthType xsi:type=xsd:stringsha1/KasAuthType SessionLifeTime xsi:type=xsd:int1800/SessionLifeTime KasUser xsi:type=xsd:stringlogin/KasUser KasPassword xsi:type=xsd:string5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8/KasPassword /v1 /ns1:KasAuth /SOAP-ENV:Body /SOAP-ENV:Envelope And here's what your latest Python sends, lifted the same way for the same reason regarding suds: ?xml version=1.0
Re: SOAPpy.Types.faultType: Cannot use object of type stdClass as array
On Thu, Mar 21, 2013 at 6:06 AM, Tamer Higazi th9...@googlemail.com wrote: SOAPpy.Types.faultType: Fault SOAP-ENV:Server: Cannot use object of type stdClass as array stdClass looks like a PHP error. Check out the server's requirements; perhaps you need to provide something as a list that you're providing as a dict, or something. I'd look at that loginData, for instance. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
SOAPpy.Types.faultType: Cannot use object of type stdClass as array
Hi poeple! I wrote a small script, and I am not getting smartwhat is ment with this error message... Any ideas?! I got this error message: SOAPpy.Types.faultType: Fault SOAP-ENV:Server: Cannot use object of type stdClass as array File /storage/PyProjects/toolsAPP/KASUpdate.py, line 32, in module KasObj = KASSystem() File /storage/PyProjects/toolsAPP/KASUpdate.py, line 27, in __init__ 'SessionLifeTime':loginData['sess_lt'],'SessionUpdateLifeTime':'Y'}) Here is the code: from SOAPpy import WSDL from SOAPpy.Errors import HTTPError as SoapHTTPError from SOAPpy.Types import faultType import hashlib class KASSystem(object): def __init__(self): WSDL_AUTH = 'https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl' WSDL_API = 'https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl' userpass = ['login','password'] m = hashlib.sha1() m.update(userpass[1]) userpass[1] = m.hexdigest() loginData = {'user':userpass[0],'pass':userpass[1]} self.__SoapServer = WSDL.Proxy(WSDL_AUTH) try: self.__CredentialToken = self.__SoapServer.KasAuth({ 'KasUser':loginData['user'], 'KasAuthType':'sha1', 'KasPassword':loginData['pass'], 'SessionLifeTime':1800,'SessionUpdateLifeTime':'Y'}) except (SoapHTTPError), e: print Fehlermeldung:, e.code,e.msg KasObj = KASSystem() -- http://mail.python.org/mailman/listinfo/python-list