mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 583 forks source link

Parsing XML response - Type error in XSD element indicators (HTTPS) #545

Open bgcarvalho opened 7 years ago

bgcarvalho commented 7 years ago

version

zeep 2.3.0

WSDL

https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl

web service help

https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/sgsAjudaIng.jsp#SA

certificates

http://www.bcb.gov.br/?CERTDIG

example

from requests import Session
from zeep import Client
from zeep.transports import Transport
import os

session = Session()
dir = os.path.dirname(os.path.abspath(__file__))
session.verify = os.path.join(dir, '../../../data/auth/cert/ca-bundle.crt')
transport = Transport(session=session)

url = 'https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl'
client = Client(url, transport=transport)
# dates in european style: DD/MM/YYYY
response = client.service.getValoresSeriesXML([433], '01/01/2017', '01/08/2017')

print(response)

error

trackback starts in client.service.getValoresSeriesXML

  File "...../venv361/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py", line 227, in render
    if name in value:
TypeError: argument of type 'int' is not iterable

I tried non-XML methods from the same web service, all worked.

Any help is appreciated.

opardal commented 6 years ago

@bgcarvalho did u get the solution for this issue?

wolfvg commented 6 years ago

I have the same error.

File "D:\WORK\Python\lib\site-packages\zeep\xsd\elements\indicators.py",  line 227, in render
    if name in value: TypeError: argument of type 'int' is not iterable

zeep 3.0.0

opardal commented 6 years ago

@wolfvg are u trying to reach BCB/SGS?

wolfvg commented 6 years ago

No, this is an internal resource.

url='http://10.10.14.31:7821/ibwbsrvc?wsdl'
session=requests.Session()
session.trust_env=False
client = Client(url, transport=Transport(session=session))
response = client.service.GetPayStatus(111)

XSD:

<xsd:element name="GetPayStatus">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="Data">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element maxOccurs="unbounded" minOccurs="1" name="ID" type="xsd:int">
                            <xsd:annotation>
                                <xsd:documentation>ID document</xsd:documentation>
                            </xsd:annotation>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
opardal commented 6 years ago

Hmm sorry, I cannot help u. I have found a workaround just for that specific webservice. I'll be waiting for someone else to answer this issue anyway...

patrickrmaia commented 4 years ago

@jadsalles Could you please share your solution to this issue? I'm having the same problem when trying to reach the SGS webservice.

opardal commented 4 years ago

Actually, I decided to get the data I needed from the api available in https://dadosabertos.bcb.gov.br/

This is not the solution, but maybe it can solve your problem also.