hecsa / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

pysimplesoap 1.12 server with python 3.2 #142

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I’m newbie on pysimplesoap 

Following steps will reproduce the problem : -

1. I have installed latest pysimplesoap 1.12 from 
https://pysimplesoap.googlecode.com/archive/1a76eb59cdf5921344c9ec667af7b25ff877
4e46.zip 

2.I'm using python 3.2

3. I'm trying to test simple client and server code copied from  
https://code.google.com/p/pysimplesoap/wiki/SoapServer 

I have converted these codes to python3.2 compatible using 2to3 utility.

Expected output should be   :- 
POST http://localhost:8008/
SOAPAction: "http://localhost:8008/Adder"
Content-length: 329
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
    <Adder xmlns="http://example.com/sample.wsdl">
    <a>1</a><b>2</b></Adder>
</soap:Body>
</soap:Envelope>

date: Tue, 20 Jul 2010 23:39:21 GMT
status: 200
content-type: text/xml
server: BaseHTTP/0.3 Python/2.5.4
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body><AdderResponse 
xmlns="http://example.com/sample.wsdl"><AddResult>3</AddResult></AdderResponse><
/soap:Body>
</soap:Envelope>

What do you see instead?

On server side i got following error prints :-

Starting server...
Traceback (most recent call last):
  File "/usr/local/lib/python3.2/dist-packages/PySimpleSOAP-1.12-py3.2.egg/pysimplesoap/server.py", line 153, in dispatch
    ns = NS_RX.findall(xml)
TypeError: can't use a string pattern on a bytes-like object

localhost - - [29/Apr/2014 16:50:21] "POST / HTTP/1.1" 500 -

On client Side I got following error prints :-

python3.2 pclient.py
INFO:pysimplesoap.client:POST http://localhost:8008/
DEBUG:pysimplesoap.client:SOAPAction: "http://localhost:8008/Adder"
Content-length: 344
Content-type: text/xml; charset="UTF-8"
DEBUG:pysimplesoap.client:b'<?xml version="1.0" 
encoding="UTF-8"?><soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n<soap:Header/>\n<soap:Bo
dy>\n    <Adder xmlns="http://example.com/sample.wsdl">\n    
<a>1</a><b>2</b></Adder>\n</soap:Body>\n</soap:Envelope>'
DEBUG:pysimplesoap.client:Server: BaseHTTP/0.6 Python/3.2.3
Date: Tue, 29 Apr 2014 11:20:21 GMT
Content-type: text/xml
DEBUG:pysimplesoap.client:b'<?xml version="1.0" 
encoding="UTF-8"?><soap:Envelope xmlns:ns0="http://example.com/sample.wsdl" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><soap:Fault><fa
ultcode>VersionMismatch.TypeError</faultcode><faultstring>can\'t use a string 
pattern on a bytes-like 
object</faultstring><detail/></soap:Fault></soap:Body></soap:Envelope>'
Traceback (most recent call last):
  File "pclient.py", line 13, in <module>
    response = client.Adder(a=1, b=2)
  File "/usr/local/lib/python3.2/dist-packages/PySimpleSOAP-1.12-py3.2.egg/pysimplesoap/client.py", line 170, in <lambda>
    return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
  File "/usr/local/lib/python3.2/dist-packages/PySimpleSOAP-1.12-py3.2.egg/pysimplesoap/client.py", line 253, in call
    raise SoapFault(unicode(response.faultcode), unicode(response.faultstring))
pysimplesoap.client.SoapFault: VersionMismatch.TypeError: can't use a string 
pattern on a bytes-like object

What version of the product are you using? On what operating system?
Im using pysimplesoap 1.12 and python 3.2 on ubuntu 12.04

Please provide any additional information below.

I did following changes as suggested by mariano reingart

"/usr/local/lib/python3.2/dist-packages/PySimpleSOAP-1.12-py3.2.egg/pysimplesoap
/server.py", line 456, in do_POST
    request = self.rfile.read(int(self.headers.getheader('content-length')))

To

    request = self.rfile.read(int(self.headers.get('content-length')))

Original issue reported on code.google.com by dipakyad...@gmail.com on 29 Apr 2014 at 11:31

GoogleCodeExporter commented 9 years ago
Python 3 support for server should be fixed in trunk 
Please download the latest version from the repository and try again.

Original comment by reingart@gmail.com on 2 May 2014 at 8:59

GoogleCodeExporter commented 9 years ago
Issue 6 has been merged into this issue.

Original comment by reingart@gmail.com on 10 May 2014 at 11:56

GoogleCodeExporter commented 9 years ago
Hi, i'm able to reproduce this exact error using the latest version from master 
branch found on github. I'm running python3.4. Could you please reopen this 
issue ?

Please tell me if I can further help you.

Original comment by julien.t...@gmail.com on 6 Oct 2014 at 10:10

GoogleCodeExporter commented 9 years ago
Hi,

I was having the same issue with version 1.16 and Python 3.4. Just in case 
anyone missed this, I solved it by adding the decode("utf-8") method to the xml 
string.

ns = NS_RX.findall(xml.decode("utf-8"))

Now my SoapServer is working just fine.

Original comment by sunset...@gmail.com on 13 Apr 2015 at 11:42