RosesDurden / pysimplesoap

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

Unicode handling #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
# Run this code
nclient = 
SoapClient(wsdl='http://ec.europa.eu/taxation_customs/vies/services/checkVatServ
ice.wsdl')
vat = 'PT508141184'
print = client.service.checkVat(countryCode=vat[:2], vatNumber=vat[2:])

What is the expected output? What do you see instead?
Something like """{'name': 'NDRIVE NAVIGATION SYSTEMS S A', 'countryCode': 
'PT', 'vatNumber': '508141184', 'valid': True, 'requestDate': 
datetime.date(2010, 9, 27), 'address': 'ESTR DA CIRCUNVALAÇÃO N 
10381\nPORTO\n4250-151 PORTO'}"""

What version of the product are you using? On what operating system?
Mercurial repo, rev. 8e831ad8fe1c (tip, at the time).

Please provide any additional information below.
>>> print client.checkVat(countryCode=vat[:2], vatNumber=vat[2:])
--------------------------------------------------------------------------------
POST http://ec.europa.eu/taxation_customs/vies/services/checkVatService
SOAPAction: "None"
Content-length: 401
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>
    <checkVat xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
    <countryCode>PT</countryCode><vatNumber>508141184</vatNumber></checkVat>
</soap:Body>
</soap:Envelope>

via: 1.0 localhost (squid/3.0.STABLE1)
proxy-connection: close
x-cache: MISS from localhost
x-cache-lookup: MISS from localhost:3128
server: WebLogic Server 8.1 SP3 Tue Jun 29 23:11:19 PDT 2004 404973
date: Mon, 27 Sep 2010 12:28:23 GMT
content-type: text/xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><urn:che
ckVatResponse 
xmlns:urn="urn:ec.europa.eu:taxud:vies:services:checkVat:types"><urn:countryCode
>PT</urn:countryCode><urn:vatNumber>508141184</urn:vatNumber><urn:requestDate>20
10-09-27+02:00</urn:requestDate><urn:valid>true</urn:valid><urn:name>NDRIVE 
NAVIGATION SYSTEMS S A</urn:name><urn:address>ESTR DA CIRCUNVALAÇÃO N 10381
PORTO
4250-151 
PORTO</urn:address></urn:checkVatResponse></soapenv:Body></soapenv:Envelope>
================================================================================
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "client.py", line 105, in <lambda>
    return lambda self=self, *args, **kwargs: self.wsdl_call(attr,*args,**kwargs)
  File "client.py", line 209, in wsdl_call
    resp = response('Body',ns=soap_uri).children().unmarshall(output)
  File "simplexml.py", line 325, in unmarshall
    value = children and children.unmarshall(fn)
  File "simplexml.py", line 335, in unmarshall
    raise ValueError("Tag: %s: %s" % (name, unicode(e)))
ValueError: Tag: address: ('ascii', u'ESTR DA CIRCUNVALA\xc7\xc3O N 
10381\nPORTO\n4250-151 PORTO', 18, 20, 'ordinal not in range(128)')

Original issue reported on code.google.com by paulo.k...@gmail.com on 27 Sep 2010 at 12:35

GoogleCodeExporter commented 8 years ago
First, your example is wrong (it seems to use suds client.service call style 
and print = is a syntax error).

The correct example is:

from client import SoapClient
client = SoapClient(wsdl='file:checkVatService.wsdl',trace=True)
vat = 'PT508141184'
response = client.checkVat(countryCode=vat[:2], vatNumber=vat[2:])
print response
print response['address']

The output is the expected:

{'name': u'NDRIVE NAVIGATION SYSTEMS S A', 'countryCode': u'PT', 'vatNumber': 
u'508141184', 'valid': True, 'requestDate': datetime.date(2010, 10, 9), 
'address': u'ESTR DA CIRCUNVALA\xc7\xc3O N 10381\nPORTO\n4250-151 PORTO'}
ESTR DA CIRCUNVALAÇÃO N 10381
PORTO
4250-151 PORTO

So, I cannot reproduce this issue, maybe there is a python unicode problem in 
your evniroment, or this depend on some platform issue.

Can you try this with the last revision from mercurial repository?
And,
Can you post your python version, operating system and console unicode settings?

Original comment by reingart@gmail.com on 9 Oct 2010 at 4:05

GoogleCodeExporter commented 8 years ago
You're right. It must have been something with my console. I've tried it in 
another computer and it works just fine (both in tip and in rev 8e831ad8fe1c).

With just looking the backtrace, I would never guess it would be a console 
problem. Sorry for the wrongful report. Thanks for your help. Keep up the good 
job. :)

Original comment by paulo.k...@gmail.com on 10 Oct 2010 at 3:11

GoogleCodeExporter commented 8 years ago

Original comment by reingart@gmail.com on 10 Oct 2010 at 7:53