mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 586 forks source link

How can I change the way of defining/binding namespaces for string array? #1270

Open RecNes opened 2 years ago

RecNes commented 2 years ago

Zeep library is generating string arrays with each child tag has it's own namespace definition:

<ns1:Images>
    <ns2:string xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        https://www.example.com/variant_image.png
    </ns2:string>
    <ns3:string xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        https://www.example.com/variant_image2.png
    </ns3:string>
    <ns4:string xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        https://www.example.com/variant_image3.png
    </ns4:string>
</ns1:Images>

But, the API I'm dealing with is strictly want the namespace of the array must be defined on parent tag and, same namespace must be used on each child tag. Eg.

<ns1:Images xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <ns2:string>https://www.siteniz.com/variant_image.png</ns2:string>
    <ns2:string>https://www.siteniz.com/variant_image2.png</ns2:string>
    <ns2:string>https://www.siteniz.com/variant_image3.png</ns2:string>
</ns1:Images>

Is there a way to force the zeep to generate string array XML like the format above?