There is a Message.RESPONSE_CODE key that would be an integer for the for 
response code.  However, I think that needs to be set on the Fault message 
that would be created as part of the fault processing.   Thus, you MAY need to 
add an interceptor to the FaultOutChain to look for your fault and adjust the 
code.

Dan


On Wed March 18 2009 5:40:25 pm HG-1 wrote:
> 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);
>         }
> }

-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to