I am using zeep (Python 3.6) to interface with a SOAP API, and working with a WSDL schema which contains this section:
<xs:element name="passengers">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="passenger" type="com:PassengerType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
So I'd like my zeep-generated XML to look like this:
<book:passengers>
<book:passenger>
...redacted...
</book:passenger>
</book:passengers>
My first attempt at achieving this with Zeep looked like this:
passengers = [factories.PassengerType()]
However, when sending this to my SOAP API, this generated the following error:
File "/usr/local/lib/python3.6/site-packages/zeep/xsd/elements/element.py", line 220, in validate
"Missing element %s" % (self.name), path=render_path)
zeep.exceptions.ValidationError: Missing element passenger (createBookingRecordRequest.passengers)
I believe this is because my 'passengers' attribute should contain a Zeep object with the tag name "passenger", which would contain my list of elements. I've tried tinkering with the zeep.xsd.AnyType
to achieve this, but haven't succeeded yet.
Any suggestions would be appreciated.