【发布时间】:2016-07-23 08:02:12
【问题描述】:
Zeep 文档示例:
from zeep import Client
client = Client('http://my-enterprise-endpoint.com')
client.service.submit_order(user_id=1, order={
'number': '1234',
'price': 99,
})
我的用例:
我想调用一个需要参数'findCriteria'的网络服务
例子:
findcriteria = {
'Criteria' : [{
'ColumnName' : 'Closed',
'Value' : 0
},
{
'ColumnName' : 'AssignToQueueID',
'Value' : queueid
},
{
'ColumnName' : 'SupportCallType',
'Value' : 'I'
}
]
}
调用服务:
打印client.service.GetCount(findCriteria = findcriteria)
这是创建的 XML:
<soap-env:Body>
<ns1:GetCount>
<ns1:findCriteria/>
</ns1:GetCount>
</soap-env:Body>
</soap-env:Envelope>
问题:
虽然服务返回计数,但不应用条件。
当我向服务提供原始 XML 负载时,结果正常。
问题出在<ns1:findCriteria/> 部分。
应为每一列创建一个 Criteria 元素。
WSDL 上 grep GetCount 的结果:
<s:element name="GetCount">
<s:element name="GetCountResponse">
<s:element minOccurs="1" maxOccurs="1" name="GetCountResult" type="s:int" />
<wsdl:message name="GetCountSoapIn">
<wsdl:part name="parameters" element="tns:GetCount" />
<wsdl:message name="GetCountSoapOut">
<wsdl:part name="parameters" element="tns:GetCountResponse" />
<wsdl:operation name="GetCount">
<wsdl:input message="tns:GetCountSoapIn" />
<wsdl:output message="tns:GetCountSoapOut" />
<wsdl:operation name="GetCount">
<soap:operation soapAction="http://<server>/webservices/SupportCall/GetCount" style="document" />
<wsdl:operation name="GetCount">
<soap12:operation soapAction="http://<server>/webservices/SupportCall/GetCount" style="document" />
【问题讨论】:
标签: python web-services soap