【发布时间】:2017-06-21 10:53:56
【问题描述】:
我已阅读有关 Spyne 故障 (http://spyne.io/docs/2.10/manual/03_types.html) 的信息,但无法通过 400 返回代码正确地引发故障。我的故障响应正确形成,但是当我需要返回 400 时,返回代码为 500。
@srpc(Boolean, _returns=String)
def requestConfiguration(value):
#if value is true, get all the data
if value == True:
#todo - get the config
return 'True Received'
else:
# if anything other than True is received, MUST respond with a SOAP fault and HTTP 400
raise Fault(faultcode="Client.", faultstring="Value must be True")
# raise error.InvalidInputError("problem", "problem")
阅读一些文档 (http://spyne.io/docs/2.10/modules/spyne/model/fault.html#Fault),我将其解释为 FaultCode 必须是一个以 Client 开头的字符串,它将返回 400 错误。 (我知道 if-else 不好,我只是想在正确编写代码之前获得一个概念证明)
我认为我需要对错误进行子类化,而不是仅仅提出它,但我无法理解它。我深入研究了代码 /protocol/soap/soap11,发现 fault_to_http_reponse_code 只返回 HTTP 500。
提前致谢
【问题讨论】:
标签: python http exception spyne