From bherman at uniqueinsuranceco.com Fri Jun 5 17:39:53 2015 From: bherman at uniqueinsuranceco.com (brian herman) Date: Fri, 05 Jun 2015 10:39:53 -0500 Subject: [Soap-Python] pysimplesoap and windows sql server In-Reply-To: <5571BFD5.6090503@uniqueinsuranceco.com> References: <5571BFD5.6090503@uniqueinsuranceco.com> Message-ID: <5571C2C9.6030908@uniqueinsuranceco.com> I have a python application that uses pysimplesoap to send a soap request to windows. The problem is the password field is not encoded in UTF-8 it may use Windows-1252? Python Code https://gist.github.com/brianherman/209af7751444ec308e1b Visual Basic Sample code (how to encode the password field in visual basic) https://gist.github.com/brianherman/b4174b99be9000fcc4f8 They use visual basic to encode the password which works. The problem is reproducing this in python This is the encoded password in the database (microsoft sql server): I have tried using the md5 package in python but I can't seem to get the encoding right. -- Brian Herman IT Department O: (773)299-7557 Unique Insurance Company We value your input, please click here to provide feedback on Unique Insurance. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/png Size: 1312 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From piet at vanoostrum.org Sun Jun 7 18:59:43 2015 From: piet at vanoostrum.org (Piet van Oostrum) Date: Sun, 7 Jun 2015 18:59:43 +0200 Subject: [Soap-Python] pysimplesoap and windows sql server In-Reply-To: <5571C2C9.6030908@uniqueinsuranceco.com> References: <5571BFD5.6090503@uniqueinsuranceco.com> <5571C2C9.6030908@uniqueinsuranceco.com> Message-ID: <21876.30847.253969.373471@cochabamba.vanoostrum.org> brian herman wrote: > I have a python application that uses pysimplesoap to send a soap request to windows. > The problem is the password field is not encoded in UTF-8 it may use Windows-1252? > Python Code > https://gist.github.com/brianherman/209af7751444ec308e1b > Visual Basic Sample code (how to encode the password field in visual basic) > https://gist.github.com/brianherman/b4174b99be9000fcc4f8 > They use visual basic to encode the password which works. The problem is reproducing this in > python > This is the encoded password in the database (microsoft sql server): > [...] > I have tried using the md5 package in python but I can't seem to get the encoding right. The VB code is strange. It uses ASCIIEncoding which only supports 7-bit codes. But the MD5 hash generates 8-bit codes and with the conversion to ASCII any code > 127 will be replaced by a question mark. You see that in the value in the databes where about half the characters are question marks. Or maybe they made the same error in the server, so that the passwords DO match. The Python code (supposing Python 2) normally would be: import hashlib m = hashlib.md5(password) print m.digest() However, if my guess is right that the characters > 127 must be replaced by question marks, the following should do it: import hashlib m = hashlib.md5(password) pw = "".join(c if c < chr(128) else '?' for c in m.digest()) print pw -- Piet van Oostrum WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] From dieter at handshake.de Mon Jun 8 08:19:08 2015 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 8 Jun 2015 08:19:08 +0200 Subject: [Soap-Python] pysimplesoap and windows sql server In-Reply-To: <5571C2C9.6030908@uniqueinsuranceco.com> References: <5571BFD5.6090503@uniqueinsuranceco.com> <5571C2C9.6030908@uniqueinsuranceco.com> Message-ID: <21877.13276.366673.634268@localhost.localdomain> brian herman wrote at 2015-6-5 10:39 -0500: >I have a python application that uses pysimplesoap to send a soap >request to windows. This is not an SOAP question; it is a question about charset encodings. >The problem is the password field is not encoded in UTF-8 it may use >Windows-1252? >Python Code >https://gist.github.com/brianherman/209af7751444ec308e1b >Visual Basic Sample code (how to encode the password field in visual basic) >https://gist.github.com/brianherman/b4174b99be9000fcc4f8 The names used in the "Visual Basic" code indicate that the password comes from an UI widget (a "text box"). Check in the UI toolkit documentation) which type (unicode or encode string) and (in the second case) which encoding the "Text" field uses. In the "Visual Basic" code, the "GetBytes" method of an "ASCIIEncoding" is applied to this value. The will transform the password value into a sequences of bytes (which is then hashed via "MD5"). Check the documentation of "ASCIIEncoding.GetBytes" to learn what it really does. It is this effect you will need to reproduce in Python (provided your Python program gets the password in the same type and the encoding). After you have got in your Python program the password as a sequence of bytes (emulating potentially a transformation to the type/encoding of the "Visual Basic" and then the effect of "ASCIIEncoding.GetBytes), you can apply Python's "md5" transformation ("import md5; hasher = md5.new(password); password_hash = hasher.digest()"). The "Visual Basic" code then uses the "ASCIIEncoding" again to convert the sequence of bytes into a "String". This likely means: 1. "String" corresponds to Python's "unicode" ("str" in Python 3) 2. "ASCIIEncoding" is badly named; it likely is in fact the "iso-8859-1" encoding (known to Python under this name). If this assumption is correct, then * you should get the "password" value as type "unicode" * you can use "password.encode('iso-8859-1')" to get the effect of "ASCIIEncoding.GetBytes(password)" * you can use "password_hash.decode('iso-8859-1')" to get the effect of "ASCIIEncoding.GetString(password_hash)". You must consult your documentation to check whether the assumptions are correct. From matthew at nocturnal.org Tue Jun 9 17:07:40 2015 From: matthew at nocturnal.org (Matthew Lenz) Date: Tue, 9 Jun 2015 10:07:40 -0500 Subject: [Soap-Python] couple questions for getting started Message-ID: Which version should I be using? The version on python package index? I am using 1.16 currently and attempting to implement the following: http://cnx.test.dat.com:9280/wsdl/TfmiFreightMatching.wsdl A login attempt is successful hooray! response = client.Login( loginOperation = { 'loginId': r'xxxxx', 'password': r'xxxxx', 'thirdPartyId': r'SampleClient', } ); .... but pysimplesoap throws an exception because it doesn't find the defs for loginSuccessData. DEBUG:pysimplesoap.client:Parsing wsdl url: http://cnx.test.dat.com:9280/wsdl/TfmiFreightMatching.wsdl DEBUG:pysimplesoap.client:Unpickle file cache/4d4952e172d281c57e33a925f49d1329.pkl INFO:pysimplesoap.client:POST http://cnx.test.dat.com:9280/TfmiRequest DEBUG:pysimplesoap.client:SOAPAction: "/Login" Content-length: 703 Content-type: text/xml; charset="UTF-8" DEBUG:pysimplesoap.client: XXXXXXXXXXXSampleClient DEBUG:pysimplesoap.client:date: Tue, 09 Jun 2015 14:54:29 GMT status: 200 content-length: 684 content-type: text/xml;charset=utf-8 server: Apache-Coyote/1.1 DEBUG:pysimplesoap.client: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2015-06-10T02:54:29.250Z Traceback (most recent call last): File "./trascore.py", line 27, in 'thirdPartyId': r'SampleClient', File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 181, in return lambda *args, **kwargs: self.wsdl_call(attr, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 346, in wsdl_call return self.wsdl_call_with_args(method, args, kwargs) File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/client.py", line 372, in wsdl_call_with_args resp = response('Body', ns=soap_uri).children().unmarshall(output) File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/simplexml.py", line 433, in unmarshall value = children and children.unmarshall(fn, strict) File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/simplexml.py", line 433, in unmarshall value = children and children.unmarshall(fn, strict) File "/usr/local/lib/python2.7/dist-packages/pysimplesoap/simplexml.py", line 380, in unmarshall raise TypeError("Tag: %s invalid (type not found)" % (name,)) TypeError: Tag: loginSuccessData invalid (type not found) loginSuccessData is based off of type SuccessData which is based off of type 'data'. All of it seems to be laid out correctly in the xsd files. I did see something that might be the reason? I saw a recent post on a help site about pysimplesoap not supporting substitution groups? (no idea what that is, completely new to this). Is that possibly the problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: From philippe at bougues.net Thu Jun 25 08:42:12 2015 From: philippe at bougues.net (Philippe B.) Date: Thu, 25 Jun 2015 08:42:12 +0200 Subject: [Soap-Python] Setting up correct namespaces in SOAP response with soaplib 2.0 Message-ID: Hello all, I'm trying to figure out how to make soaplib produce a server-side response with appropriate name spaces. I mostly use the __namespace__ attribute in classes, but it doesn't seem to work the way I'd like. Here is a simplified example; I'd like to get the following output : Some data Some more data <- I want this one to be without NS A field without NS In order to get this I do the following declarations: class ThirdNSString(String): __namespace__ = "my_third_ns" class FirstItemClass(ClassModel): __namespace__ = "my_first_ns" field1 = ThirdNSString field2 = String class MyFunctionResponseClass(ClassModel): __namespace__ = "my_first_ns" FirstItem = FirstItemClass class SecondItemClass(ClassModel): __namespace__ = "my_fourth_ns" #<- I'd like it to be empty; if this is not declared, the script crashes field = String The data is produced as follows : rep = MyFunctionResponseClass() rep.FirstItem = FirstItemClass() rep.FirstItem.field1 = "Some data" rep.FirstItem.field2 = "Some more data" rep.SecondItem = SecondItemClass() rep.SecondItem.field = "A field without NS" return rep However here is the output I get : A field without NS Some more data Some data Would someone be kind enough to help me figure it out ? Thanks in advance. -- Philippe -------------- next part -------------- An HTML attachment was scrubbed... URL: From burak.arslan at arskom.com.tr Thu Jun 25 10:28:40 2015 From: burak.arslan at arskom.com.tr (Burak Arslan) Date: Thu, 25 Jun 2015 11:28:40 +0300 Subject: [Soap-Python] Setting up correct namespaces in SOAP response with soaplib 2.0 In-Reply-To: References: Message-ID: <558BBBB8.3000301@arskom.com.tr> hello, On 06/25/15 09:42, Philippe B. wrote: > <- I want this one to be without NS it's not possible. you need sub_ns functionality from spyne 2.12. in case you did not know, soaplib was what spyne was called more than 3, maybe 4 years ago. best, burak -------------- next part -------------- An HTML attachment was scrubbed... URL: From philippe at bougues.net Thu Jun 25 12:06:34 2015 From: philippe at bougues.net (Philippe B.) Date: Thu, 25 Jun 2015 12:06:34 +0200 Subject: [Soap-Python] Setting up correct namespaces in SOAP response with soaplib 2.0 In-Reply-To: <558BBBB8.3000301@arskom.com.tr> References: <558BBBB8.3000301@arskom.com.tr> Message-ID: Thanks Burak. I'll check the latest Spyne for these features. 2015-06-25 10:28 GMT+02:00 Burak Arslan : > hello, > > On 06/25/15 09:42, Philippe B. wrote: > > <- I want this one to be without NS > > > it's not possible. you need sub_ns functionality from spyne 2.12. > > in case you did not know, soaplib was what spyne was called more than 3, > maybe 4 years ago. > > best, > burak > > > > _______________________________________________ > Soap mailing list > Soap at python.org > https://mail.python.org/mailman/listinfo/soap > > -------------- next part -------------- An HTML attachment was scrubbed... URL: