2

I'm using the Python library zeep to talk to a SOAP service. One of the required arguments in the documentation is of type List<String> and in the WSDL I found this:

<xs:element minOccurs="0" maxOccurs="1" name="IncludedLenders" type="tns:ArrayOfString"/>

And I believe AraryOfString is defined as:

<xs:complexType name="ArrayOfString">
  <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

How do I make zeep generate the values for that? I tried with:

"IncludedLenders": [
  "BMS",
  "BME"
]

but that generates:

                <ns0:IncludedLenders>
                    <ns0:string>BMS</ns0:string>
                </ns0:IncludedLenders>

instead of:

                <ns0:IncludedLenders>
                    <ns0:string>BMS</ns0:string>
                    <ns0:string>BME</ns0:string>
                </ns0:IncludedLenders>

Any ideas how to generate the later?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

1 Answers1

2

I figured out. First I needed to extract the ArrayOfString type:

array_of_string_type = client.get_type("ns1:ArrayOfString")

and then create it this way:

"IncludedLenders": array_of_string_type(["BMS","BME"])
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • Worth noting, this also works with any ArrayOfXXX like objects, including custom ones (ex "ns0:ArrayOfGarantie"); In any case the intermediate objects (string, Garantie, ...) are "magically" created, so you don't need to create them ! (I ended with Array of Object of Object at my first attempt) – Corentin Jacquet Jan 25 '23 at 16:38