我对 zeep 和肥皂很陌生。我正在尝试向肥皂 ws 功能发出客户端请求。wsdl的功能:
-<s:element name="GetRetailTransactions">
-<s:complexType>
-<s:sequence>
-<s:element name="parameters" maxOccurs="1" minOccurs="0">
-<s:complexType mixed="true">
-<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
我不完全了解如何在 zeep 中创建任何类型的对象。我努力了 :
wsdl = 'http://domain/app.asmx?WSDL'
client = Client(wsdl=wsdl)
params = {
'RetailTransactionsParameters': {
'GetNotExportedOnly': '0',
'GetNotRetrunsOnly': '0',
'FromDate': '20170518',
'ToDate': '20170518',
'TransactionTypeFilter': {
'TransactionType': '2'
},
},
}
parameters = client.get_element('ns0:GetRetailTransactions')
param = xsd.AnyObject(parameters, parameters(params))
result = client.service.GetRetailTransactions(param)
但我得到错误:
File "/home/user/lib/python3.6/site-packages/zeep/xsd/elements/indicators.py", line 227, in render
if name in value:
TypeError: argument of type 'AnyObject' is not iterable
在soapui上,我可以提出请求并成功获得答案:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<GetRetailTransactions xmlns="example.com/">
<parameters>
<RetailTransactionsParameters>
<GetNotExportedOnly>0</GetNotExportedOnly>
<GetNotRetrunsOnly>0</GetNotRetrunsOnly>
<FromDate>20170518</FromDate>
<ToDate>20170518</ToDate>
<TransactionTypeFilter>
<TransactionType>2</TransactionType>
</TransactionTypeFilter>
</RetailTransactionsParameters>
</parameters>
</GetRetailTransactions>
</Body>
</Envelope>
也许有人可以指导我如何正确地用 zeep 提出这样的请求。在此先感谢