Axis 1.4 Java: Modify HTTP response code

Posted by Achim Bitzer on Stack Overflow See other posts from Stack Overflow or by Achim Bitzer
Published on 2010-04-13T08:51:10Z Indexed on 2010/04/13 8:52 UTC
Read the original article Hit count: 844

Filed under:
|
|
|
|

Hello,

Is there a way to modify the HTTP response code when using apache axis 1.4 for java?

This would be useful for testing purposes, for example simulating server side errors.

I've already tried the following:

Set the HTTP code directly in the http servlet Request:

  MessageContext context = MessageContext.getCurrentContext();

  HttpServletResponse response = (HttpServletResponse) context.getProperty(
      HTTPConstants.MC_HTTP_SERVLETRESPONSE);
  response.setStatus(e.getErrorCode()); // no effect

Set the HTTP code as axis message context property:

MessageContext context = MessageContext.getCurrentContext();
context.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, e.getErrorCode());

But this didn't seem to work, the actual HTTP code always was 200.

Any ideas would be greatly appreciated :-)

Greetings,

Achim Bitzer

© Stack Overflow or respective owner

Related posts about axis

Related posts about java