You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Zeep调用SOAP服务时遇'Service has no operation'错误求助

解决Zeep调用SOAP服务时找不到getPlansDetails方法的问题

我帮你分析下这个问题哈,从你提供的python -m zeep <wsdl_url>输出信息来看,问题根源很明确:

你的SOAP服务RoutingService有两个端口,而getPlansDetails操作只存在于BasicHttpBinding_LFCPaymentPlanDetailsServices这个端口下,但Zeep默认绑定的是另一个端口serviceEndpoint——这个端口里并没有你要调用的方法,所以才会抛出AttributeError: Service has no operation 'getPlansDetails'。

下面给你两种可行的解决方法:

方法一:显式绑定目标端口后调用

创建Client实例后,先获取对应端口的服务代理,再调用方法:

client = Client(self.const.soap_url)
# 绑定指定的服务和端口
service = client.bind('RoutingService', 'BasicHttpBinding_LFCPaymentPlanDetailsServices')
# 调用方法,注意参数名是_crmno(和WSDL定义一致)
response = service.getPlansDetails(_crmno=id)

方法二:直接通过端口路径调用

也可以直接通过端口的命名空间路径来调用方法:

client = Client(self.const.soap_url)
# 直接指定端口下的方法
response = client.service.BasicHttpBinding_LFCPaymentPlanDetailsServices.getPlansDetails(_crmno=id)

额外注意事项

从WSDL输出能看到,getPlansDetails还支持可选的SOAP Header参数context(类型为ns4:CallContext),如果你的服务需要传入公司信息、语言设置等上下文参数,可以这样构造并传入:

client = Client(self.const.soap_url)
service = client.bind('RoutingService', 'BasicHttpBinding_LFCPaymentPlanDetailsServices')
# 构造CallContext对象,根据实际需求填写字段
call_context = client.get_type('ns4:CallContext')(
    Company='你的公司代码',
    Language='zh-CN'
)
# 传入SOAP Header调用方法
response = service.getPlansDetails(_crmno=id, _soapheaders={'context': call_context})

内容的提问来源于stack exchange,提问作者Ranjith Ramachandra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 16:52:27