如何在zeep中访问方法

时间:2019-03-13 10:29:15

标签: python zeep

我正在尝试以下代码,但得到了zeep.exceptions.Fault:null 错误

from zeep import Client
from zeep.transports import Transport
from requests_ntlm import HttpNtlmAuth
from requests import Session
session = Session()
username = ""
password = ""
url = ""
session.auth = HttpNtlmAuth(username,password)
transport = Transport(session=session)
client = Client(url,transport=transport)
client.service.CI_Z_SP_PERS_DTL_CI_G(EMPLID="001670")

1 个答案:

答案 0 :(得分:0)

这不是答案,但是以下方法可以帮助捕获代码中错误的来源。要获取导致代码中出现行/代码段的实际错误,可以使用try / except块来捕获错误:

#<---code--->
try:
    session.auth = HttpNtlmAuth(username,password)
    transport = Transport(session=session)
    client = Client(url,transport=transport)
    client.service.CI_Z_SP_PERS_DTL_CI_G(EMPLID="001670")
except zeep.exceptions.Fault as fault:
    print fault.message
    print fault.code
    print fault.actor

OR

except zeep.exceptions.Fault as fault:
    print fault.__dict__

这将有助于调试错误发生的确切位置。