Pablo Fernandez
Pablo Fernandez

Reputation: 287780

How to generate a List<String> with zeep?

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?

Upvotes: 2

Views: 1840

Answers (1)

Pablo Fernandez
Pablo Fernandez

Reputation: 287780

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"])

Upvotes: 2

Related Questions