mvantellingen / python-zeep

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

Zeep fails to parse `24:00:00` as `xsd:time` (ValueError: hour must be in 0..23) #1401

Open Trolldemorted opened 6 months ago

Trolldemorted commented 6 months ago

Zeep uses isodate to parse xsd:time:

https://github.com/mvantellingen/python-zeep/blob/377d9313b1b4807a31a5ee42227f1dc7e7e0471e/src/zeep/xsd/types/builtins.py#L197-L198

isodate does not like 24:00:00 and throws ValueError: hour must be in 0..23, but 24:00:00 should be a valid value of xsd:time: http://www.datypic.com/sc/xsd/t-xsd_time.html

We are using zeep 4.2.1 and isodate 0.6.1.

Our (stupid) workaround was to replace xsd:time with xsd:string.

alixepstein commented 4 weeks ago

I'm having the same problem. Can you specify WHERE you replace xsd:time with xsd:string? I don't have that in my code so I can't do that... I feel like a real idiot. Here's my code (with a hard-coded start time):

``wsdl_url = "https://webservices.chargepoint.com/cp_api_5.1.wsdl" client = Client(wsdl_url, wsse=UsernameToken(cpusername, cppassword))

def FleetUsageAPIcall(client): eastern_tz = pytz.timezone('America/New_York') now = datetime.now(ZoneInfo('America/New_York')) fleetusagedf = pd.DataFrame() tStart = datetime(2024, 5, 15, 00, 00, 00, tzinfo=eastern_tz) while tStart < now: tEnd = tStart + timedelta(days=10) searchQuery = {'fromTimeStamp': tStart, 'toTimeStamp': tEnd} fleetUsageData = client.service.getFleetUsageData(searchQuery) fleetusagedf = pd.concat([fleetusagedf, pd.DataFrame(helpers.serialize_object(fleetUsageData.fleetUsageData))]) tStart = tStart + timedelta(days = 10) if tStart > now: break return fleetusagedf

fleetusagedf = FleetUsageAPIcall(client)``

Trolldemorted commented 3 weeks ago

It's inside your SOAP api definition: