I have wsdl with ArrayOfVEHICLE type:
<xs:complexType name="ArrayOfVEHICLE">
<xs:sequence>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="VEHICLE" nillable="true" type="tns:VEHICLE"/>
<xs:element name="VEHICLEV2" nillable="true" type="tns:VEHICLEV2"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
I am trying to create element with that type with zeep:
vehicle_v2_type = client.get_type("ns0:ArrayOfVEHICLE")
vehicle_v2 = vehicle_v2_type(VEHICLEV2={...})
And I get an error:
TypeError: {http://www.vsk.ru}ArrayOfVEHICLE() got an unexpected keyword argument 'VEHICLE2'. Signature: `({VEHICLE: {http://www.vsk.ru}VEHICLE} | {VEHICLEV2: {http://www.vsk.ru}VEHICLEV2})[]`
I have tried using _value_1 method from zeep docs like this:
vehicle_v2 = vehicle_v2_type(_value_1={"VEHICLEV2": {...}})
And I get another error:
TypeError: No complete xsd:Sequence found for the xsd:Choice '_value_1'.
The signature is: ({VEHICLE: {http://www.vsk.ru}VEHICLE} | {VEHICLEV2: {http://www.vsk.ru}VEHICLEV2})[]
Anybody knows how to create that element with zeep?
Ok, i got it. My wsdl says that choise element got to be list, because of signature:
<xs:choice maxOccurs="unbounded" minOccurs="0">
And the easy way is to create Nested list using _value_1 , without factories in my case
client.service.SomeService(
...
vehicles={ # Element with ArrayOfVEHICLE type
"_value_1" : [
{
"VEHICLE2": {...}
}
]
}
)
Hope this wil help someone
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.