Returning different statuscode in cXML must I also send HTTP Statuscode back?

空扰寡人 提交于 2019-12-25 09:03:47

问题


In CXML if the Sender credentials was not correct then in my cxml I send this as a response back to the sender of the cXML post:

<Status code="401" text="Unauthorized ">Credentials provided in the Request (the Sender element) were not recognized by the server.</Status>

According to cXML this is correct. But do I also need to change my HTTP statuscode to 401 or will 200 OK suffice?


回答1:


As It is mentioned in the cxml User Guide cxml error handling is on top of http (transport layer) error message, you can see them as functional errors so you still reply with an HTTP 200

3.1.9.1 Status

Because cXML is layered above HTTP in most cases, many errors (such as HTTP 404/Not Found) are handled by the transport. All transport errors should be treated as transient and the client should retry, as if a cXML 500 range status code had been received. All HTTP replies that don’t include valid cXML content, including HTTP 404/Not found and HTTP 500/Internal Server Error status codes, are considered transport errors. Other common transport problems include timeouts, TCP errors (such as “connection refused”), and DNS errors (such as “host unknown”). Validation errors in parsing a Request document would normally result in a cXML permanent error in the 400 range, preferably 406/Not Acceptable.

In your case, you want to reply with

  • HTTP 200 / OK answer
  • cXML 401 / Unauthorized


来源:https://stackoverflow.com/questions/43383929/returning-different-statuscode-in-cxml-must-i-also-send-http-statuscode-back

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!