问题描述
我正在使用 zeep python 包,以便通过接受的 SOAP 调用函数'ArrayofInt' 类型的参数.
I am using the zeep python package so as to call a function through SOAP which accepts an argument of 'ArrayofInt' type.
传递普通"整数数组不起作用...解决方法是使用 for 循环遍历数组的元素并逐个发送元素,但这不是我拥有的最干净的代码曾经写过:)
Passing a 'normal' integer array doesn't work... the workaround is to run through the elements of the array with a for loop and send the elements one-by-one but this is not the cleanest code I have ever written:)
有什么建议吗?
推荐答案
这个 回答会帮你解决问题.
使用 Zeep 的 client.get_type 函数创建一个空的 Zeep ArrayOfInt 对象,然后通过它循环数组.
This answer will sort you out.
Use the Zeep's client.get_type function to create an empty Zeep ArrayOfInt object and then loop your array through it.
client = Client(soap_url)
test_list = [1,2,3,4]
emptyArrayPlaceholder = client.get_type('ns0:ArrayOfInt')
options = emptyArrayPlaceholder()
for el in test_list:
options['int'].append(el)
这篇关于将python的int数组转换为SOAP ArrayofInt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!