python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

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

Open bgcarvalho opened this issue 9 years ago • 7 comments

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.

bgcarvalho avatar Aug 20 '17 15:08 bgcarvalho

@bgcarvalho did u get the solution for this issue?

opardal avatar May 27 '18 22:05 opardal

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

wolfvg avatar Jul 24 '18 13:07 wolfvg

@wolfvg are u trying to reach BCB/SGS?

opardal avatar Jul 25 '18 14:07 opardal

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>

wolfvg avatar Jul 26 '18 14:07 wolfvg

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...

opardal avatar Jul 26 '18 22:07 opardal

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

patrickrmaia avatar Aug 05 '20 13:08 patrickrmaia

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.

opardal avatar Aug 06 '20 19:08 opardal