use*_*674 9 python soap wsdl zeep
我有一个包含复杂类型的WSDL,如下所示:
<xsd:complexType name="string_array">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
Run Code Online (Sandbox Code Playgroud)
我决定对soap客户端使用zeep,并希望将该类型用作WSDL中引用的其他方法之一的参数.我似乎无法弄清楚如何使用这种类型.当我通过看文件关于如何使用WSDL中引用的某些数据结构,它说,使用client.get_type()方法,所以我做了以下内容:
wsdl = "https://wsdl.location.com/?wsdl"
client = Client(wsdl=wsdl)
string_array = client.get_type('tns:string_array')
string_array('some value')
client.service.method(string_array)
Run Code Online (Sandbox Code Playgroud)
这给出了一个错误TypeError: argument of type 'string_array' is not iterable.我也试过很多变化,并尝试使用这样的字典:
client.service.method(param_name=['some value'])
Run Code Online (Sandbox Code Playgroud)
这给出了错误
ValueError: Error while create XML for complexType '{https://wsdl.location.com/?wsdl}string_array': Expected instance of type <class 'zeep.objects.string_array'>, received <class 'str'> instead.`
Run Code Online (Sandbox Code Playgroud)
如果有人知道如何使用带有zeep的WSDL中的上述类型,我将不胜感激.谢谢.
Kca*_*ats 12
client.get_type()方法返回一个'类型构造函数',您可以在以后使用它来构造该值.您需要将构造的值分配给单独的变量,并在方法调用中使用该变量:
wsdl = "https://wsdl.location.com/?wsdl"
client = Client(wsdl=wsdl)
string_array_type = client.get_type('tns:string_array')
string_array = string_array_type(['some value'])
client.service.method(string_array)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8974 次 |
| 最近记录: |