I am using interceptor to check for existence of particular headers. If
headers are not there, then I want to the HTTP response to be a specific
HTTP resonse. But it seems that if I throw a fault, it always it always
returns 500 response. How can I send custom response codes in interceptor?
Here is my sample interceptor:
public class AuthCxfInterceptor extends AbstractPhaseInterceptor<Message>
{
public AuthCxfInterceptor()
{
super(Phase.READ);
}
@Override
public void handleMessage(Message message) throws Fault
{
HashMap pheaders = (HashMap) message.get(Message.PROTOCOL_HEADERS);
Exception unauthException = new
WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
List<?> hdrValues = (List<?>) pheaders.get("myheaderkey");
if (hdrValues.size() < 1)
{
log.info("Missing myheaderkey");
throw new Fault(unauthException);
}
}
--
View this message in context:
http://www.nabble.com/Set-HTTP-Response-in-Interceptor-tp22589098p22589098.html
Sent from the cxf-user mailing list archive at Nabble.com.