Skip to content

Commit

Permalink
SWS-804 - WebServiceMessageReceiverHandlerAdapter not easily overrida…
Browse files Browse the repository at this point in the history
…ble to produce SOAP faults
  • Loading branch information
poutsma committed Nov 30, 2012
1 parent a66a7d4 commit 4296756
Showing 1 changed file with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public ModelAndView handle(HttpServletRequest httpServletRequest,
handleConnection(connection, (WebServiceMessageReceiver) handler);
}
catch (InvalidXmlException ex) {
httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
handleInvalidXmlException(httpServletRequest, httpServletResponse, handler, ex);
}
}
else {
httpServletResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
handleNonPostMethod(httpServletRequest, httpServletResponse, handler);
}
return null;
}
Expand All @@ -72,4 +72,38 @@ public boolean supports(Object handler) {
return handler instanceof WebServiceMessageReceiver;
}

/**
* Template method that is invoked when the request method is not {@code POST}. Called from {@link
* #handle(HttpServletRequest, HttpServletResponse, Object)}.
* <p/>
* Default implementation set the response status to 405: Method Not Allowed. Can be overridden in subclasses.
*
* @param httpServletRequest current HTTP request
* @param httpServletResponse current HTTP response
* @param handler current handler
*/
protected void handleNonPostMethod(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
Object handler) throws Exception {
httpServletResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

/**
* Template method that is invoked when parsing the request results in a {@link InvalidXmlException}. Called from
* {@link #handle(HttpServletRequest, HttpServletResponse, Object)}.
* <p/>
* Default implementation set the response status to 400: Bad Request. Can be overridden in subclasses.
*
* @param httpServletRequest current HTTP request
* @param httpServletResponse current HTTP response
* @param handler current handler
* @param ex the invalid XML exception that resulted in this method being called
*/
protected void handleInvalidXmlException(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse,
Object handler,
InvalidXmlException ex) throws Exception {
httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}

}

0 comments on commit 4296756

Please sign in to comment.