当我用 zeep 调用肥皂服务时,我正在尝试获取错误详细信息。
如何解析zeep.exceptions.Fault.detail?它返回 lxml.etree._Element。
我正在使用这段代码:
try:
client = Client(wsdl=self.__wsdl)
response = client.service.CustomerInformation(CustomerInformationService=self.service, faultStyle='wsdl')
except Fault as error:
detail = error.detail
# parse detail here
这是响应 XML:
<?xml version="1.0" ?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body >
<soap-env:Fault >
<faultcode>soap-env:Client</faultcode>
<faultstring>Client Error</faultstring>
<detail>
<ouaf:Fault xmlns:ouaf="urn:oracle:ouaf">
<ResponseStatus>F</ResponseStatus>
<ResponseCode>2013</ResponseCode>
<ResponseText>
Error while executing the request:
(Server Message)
Category: 90006
Number: 32200
Call Sequence:
Program Name: CustomerInformationService
Text: The personal account was not found: 9134211141
Description:
Table: null
Field: null
</ResponseText>
<ResponseData numParm="1" text="The personal account was not found: 9134211141" category="90006" number="32200" parm1="9134211141" />
</ouaf:Fault>
</detail>
</soap-env:Fault>
</soap-env:Body >
</soap-env:Envelope>
我的 wsdl 中存在与 xml 数据的“故障”类型的区别。