Petals BC REST

allow to return an empty answer on a fault

Details

  • Type: Improvement Request Improvement Request
  • Status: New New
  • Resolution: Unresolved
  • Affects Version/s: 1.3.0-BC
  • Fix Version/s: None
  • Component/s: Consumer mode
  • Security Level: Public
  • Description:
    Hide

    When we return a business mistake we should not be able to give body to the answer.
    For example, a 404 error is self-sufficient; there is no need to re-specify what led to it (the parameters of the call are already known to the caller).

    In this case the HTTP response could be
    HTTP/1.1 404 Not Found
    Date: Sun, 18 Oct 2012 10:36:20 GMT
    Connection: Closed

    Currently it is obligatory to provide an answer. If no transformation is provided it is the object to use to throw the error that is used for the response.
    With a transformation, an object must be returned, otherwise a technical error is thrown (org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Premature end of fil etc.).

    Ideally, there should be a configuration parameter in the fault handling to indicate that you do not want to provide a body for the response.

    for example :
    <rest:on-fault order-id="0">
    <rest:condition>
    <rest:xpath>boolean(/*[local-name()='objetc-not-found'])</rest:xpath>
    </rest:condition>
    <rest:http-response http-code="404">
    <rest:transformation>
    <rest:no-body>true</rest:no-body>
    </rest:transformation>
    </rest:http-response>
    </rest:on-fault>

    or
    <rest:on-fault order-id="0">
    <rest:condition>
    <rest:xpath>boolean(/*[local-name()='objetc-not-found'])</rest:xpath>
    </rest:condition>
    <rest:http-response http-code="404" no-body="true"/>
    </rest:on-fault>

    The goal is to have a clear parameter is easily identifiable.
    Hooking this parameter on HttpResponse allows to make this behavior on any response and force this behavior independently of the detected type of orperation.

    Show
    When we return a business mistake we should not be able to give body to the answer. For example, a 404 error is self-sufficient; there is no need to re-specify what led to it (the parameters of the call are already known to the caller). In this case the HTTP response could be HTTP/1.1 404 Not Found Date: Sun, 18 Oct 2012 10:36:20 GMT Connection: Closed Currently it is obligatory to provide an answer. If no transformation is provided it is the object to use to throw the error that is used for the response. With a transformation, an object must be returned, otherwise a technical error is thrown (org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 1; Premature end of fil etc.). Ideally, there should be a configuration parameter in the fault handling to indicate that you do not want to provide a body for the response. for example : <rest:on-fault order-id="0"> <rest:condition> <rest:xpath>boolean(/*[local-name()='objetc-not-found'])</rest:xpath> </rest:condition> <rest:http-response http-code="404"> <rest:transformation> <rest:no-body>true</rest:no-body> </rest:transformation> </rest:http-response> </rest:on-fault> or <rest:on-fault order-id="0"> <rest:condition> <rest:xpath>boolean(/*[local-name()='objetc-not-found'])</rest:xpath> </rest:condition> <rest:http-response http-code="404" no-body="true"/> </rest:on-fault> The goal is to have a clear parameter is easily identifiable. Hooking this parameter on HttpResponse allows to make this behavior on any response and force this behavior independently of the detected type of orperation.
  • Environment:
    petals 5.2 bc-rest 1.3.0

People

Dates

  • Created:
    Tue, 8 Oct 2019 - 17:27:54 +0200
    Updated:
    Tue, 8 Oct 2019 - 17:27:54 +0200