相关疑难解决方法(0)

如何在Python中使用带有zeep的WSDL中的复杂类型

我有一个包含复杂类型的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中的上述类型,我将不胜感激.谢谢.

python soap wsdl zeep

9
推荐指数
1
解决办法
8974
查看次数

标签 统计

python ×1

soap ×1

wsdl ×1

zeep ×1