I have this element that i have to use as a parameter in a service:
ns0:tMensajeEjecucionConsulta(CodConsulta: ns0:tCodConsulta, Parametros: {[({Txt:
{n: ns0:n, v: ns0:v}} | {Num: {n: ns0:n, v: xsd:decimal}} | {Fec: {n: ns0:n, v:
xsd:date}} | {Ses: {n: ns0:n, v: ns0:v}})]})
I made an object like this:
data = {
'CodConsulta': {'v': '5473'},
'Parametros': [
{'Txt': {'n': 'Agente', 'v': 'Test'}},
{'Fec': {'n': 'Fecha', 'v': '2021-10-28'}},
]}
request = client.get_type('ns0:tMensajeEjecucionConsulta')
data = request(**data)
response = client.service.ServicioEjecucionConsultaEncolumnada(data)
Parametros() got an unexpected keyword argument 'Txt'. Signature: `[({Txt: {n: {http://www.omel.es/Schemas}n, v: {http://www.omel.es/Schemas}v}} | {Num: {n: {http://www.omel.es/Schemas}n, v: xsd:decimal}} | {Fec: {n: {http://www.omel.es/Schemas}n, v: xsd:date}} | {Ses: {n: {http://www.omel.es/Schemas}n, v: {http://www.omel.es/Schemas}v}})]
I've also tried like this:
request = client.get_type('ns0:tMensajeEjecucionConsulta')
data = request(CodConsulta='5473', Parametros=[
{'Txt': {'n': 'Agente', 'v': 'Test'}},
{'Fec': {'n': 'Fecha', 'v': '2021-10-28'}},
])
response = client.service.ServicioEjecucionConsultaEncolumnada(data)
It gave me exactly the same error.
I'm not able to form the object Parametros correctly. Can anyone give me an hint why?
I figure it out. This element happens to be a
xsd:choiceone. And the structures for that type of element are different from the usual.The documentation for handling this type of elements is available here: https://docs.python-zeep.org/en/master/datastructures.html#xsd-choice
In the end my valid object had to be like this: