I have implemented a webservice and successfully exposed it via soap
using CXF. I have now been asked to set an http response code of 404
under certain conditions. Though I am not in agreement with straying
into unspecified behavior, I don't have much choice in the matter. I
have tried everything I could find in the documentation to do this,
but cannot make it work.
I have successfully acquired the web service context using:
@Resource
WebServiceContext wsc;
At the point I usually return a value from the service, I have tried
both:
MessageContext context = wsc.getMessageContext();
context.put(Message.RESPONSE_CODE, new Integer(404));
and
HttpServletResponse response = (HttpServletResponse)
context.get(AbstractHTTPDestination.HTTP_RESPONSE);
response.setStatus(new Integer(404));
In either case, the status code actually received is 200/OK
What, if any, is the proper way to do this?
Thanks in advance for any help.