Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-609

sendError instead of setStatus

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.5.9, 2.0 M1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Hi

      All invocations of HttpServletResponse#setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); should be replaced by
      HttpServletResponse#sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);.

      In servlet 2.3 sendError and sendStatus (with error code) worked the same but in Servlet 2.4 spec, response.sendError() and response.setStatus() are treated differently.

      The former is used to signal errors and it redirects you to the configured error page, the latter is to be used to set status for non-error response and it still assumes that you're going to be providing the response yourself.

      In current versions of SWS (both 1.5.X and 2.X) if you make a HTTP request that causes setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED) call , you will always get a default container-provided error-page as a response. No error-page configuration is consulted.
      For requests that result in soap fault it is ok to use setStatus(500) and send back soap fault to user, but for other cases sendError() should be called.

      Currenly i am using a workaround: built a custom HTTPServletFilter to check if response status is HttpServletResponse.SC_METHOD_NOT_ALLOWED and then call sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED)

      According to FishEye search this change would touch following classes:
      WebServiceMessageReceiverHandlerAdapter.java, XsdSchemaHandlerAdapter.java, HttpServletConnection.java (
      getHttpServletResponse().setStatus(HttpTransportConstants.STATUS_NOT_FOUND); ??? ), WsdlDefinitionHandlerAdapter.java

        Attachments

          Activity

            People

            Assignee:
            arjen.poutsma Arjen Poutsma
            Reporter:
            miluch Jakub Milkiewicz
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: