python-zeep
python-zeep copied to clipboard
Zeep fails to parse `24:00:00` as `xsd:time` (ValueError: hour must be in 0..23)
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.
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)``
It's inside your SOAP api definition:
- download https://webservices.chargepoint.com/cp_api_5.1.wsdl
- replace all 5 occurences of
type="xsd:time"withtype="xsd:string" - invoke
Clientconstructor with your modified version of cp_api_5.1.wsdl instead of the original upstream one