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

使用Zeep调用BRENDA数据库API遇AttributeError问题求助

Fixing AttributeError: 'Client' object has no attribute 'getKmValue' with Zeep

The issue here is that Zeep handles SOAP method calls differently than SOAPpy — you can't call methods directly on the Client object. Instead, you need to access the service layer exposed by the WSDL. Here's how to fix your code:

Step 1: Verify Available Services and Methods

First, let's inspect what services and methods Zeep has parsed from the BRENDA WSDL to confirm getKmValue exists:

import zeep
import hashlib

wsdl = "https://www.brenda-enzymes.org/soap/brenda.wsdl"
password = hashlib.sha256("xx".encode('utf-8')).hexdigest()
parameters = "xxx," + password + ",ecNumber*{}#organism*{}#".format("2.7.1.2", "Homo sapiens")

client = zeep.Client(wsdl=wsdl)

# Print all available services in the WSDL
print("Available services:", list(client.wsdl.services.keys()))
# For the BRENDA WSDL, the service is typically 'BrendaService'
service = client.wsdl.services['BrendaService'].ports['BrendaPort']
# Print all methods exposed by this port
print("Available methods:", [op.name for op in service.operations])

This will show you exactly what method names you can use (in case there's a capitalization difference like GetKmValue instead of getKmValue).

Step 2: Call the Method Correctly

Once you confirm getKmValue is available, use the client.service attribute to access the SOAP methods (Zeep binds to the default service/port automatically):

import zeep
import hashlib

wsdl = "https://www.brenda-enzymes.org/soap/brenda.wsdl"
password = hashlib.sha256("xx".encode('utf-8')).hexdigest()
parameters = "xxx," + password + ",ecNumber*{}#organism*{}#".format("2.7.1.2", "Homo sapiens")

client = zeep.Client(wsdl=wsdl)
# Access the service layer and call the method
km_string = client.service.getKmValue(parameters)
print(km_string)

Fallback: Explicitly Specify Service and Port

If the above doesn't work, explicitly target the service and port from the WSDL:

import zeep
import hashlib

wsdl = "https://www.brenda-enzymes.org/soap/brenda.wsdl"
password = hashlib.sha256("xx".encode('utf-8')).hexdigest()
parameters = "xxx," + password + ",ecNumber*{}#organism*{}#".format("2.7.1.2", "Homo sapiens")

client = zeep.Client(wsdl=wsdl)
# Get the specific service and port
brenda_service = client.wsdl.services['BrendaService']
brenda_port = brenda_service.ports['BrendaPort']
# Call the method directly on the port
km_string = brenda_port.getKmValue(parameters)
print(km_string)

This should resolve the AttributeError since you're now accessing the method through the correct service/port layer instead of the base Client object.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.13 08:09:55