Yep,
I ran into the same problem a while back. Here is what I came up with..
public class FlexFaultResponseInterceptor extends
AbstractPhaseInterceptor<Message> {
public FlexFaultResponseInterceptor() {
super(Phase.POST_PROTOCOL);
}
/*
* (non-Javadoc)
*
* @see
org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
*/
�...@suppresswarnings("unchecked")
public void handleMessage(Message message) throws Fault {
Message in = message.getExchange().getInMessage();
Map<String, Object> headers = (Map<String, Object>)
in.get(Message.PROTOCOL_HEADERS);
Object flashVersion = headers.get("x-flash-version");
if (flashVersion != null) {
message.put(Message.RESPONSE_CODE, new Integer(200));
}
}
}
This one checks to make sure that it's Flex that asking for the service (via
the x-flash-version header) and swaps to a 200 return code if that's the case.
Like Dan said, add it to the fault out chain to override the default behavior.
Hope that helps,
Derek
________________________________
From: Daniel Kulp <[email protected]>
To: [email protected]
Cc: stargex <[email protected]>
Sent: Friday, April 3, 2009 5:18:05 PM
Subject: Re: CXF Fault Response Code
You would probably need to add an interceptor onto the FaultOutChain that sets
the Message.RESPONSE_CODE property on the message to 200. I THINK that will
work.
Dan
On Fri April 3 2009 2:44:52 pm stargex wrote:
> I have created a CXF 2.1.3 web service server and I have a Flex client.
> The problem I am having is that I need faults to return with a HTTP
> response code of 200 and not 500. Flex can't get any fault information
> when they are sent with a HTTP code of 500.
>
> I have looked and I can't seem to figure out how to change the response
> code sent by my CXF web service. Is it possible to do this and if so how
> can I do it?
>
> If it makes a difference I have created pro grammatically and not through
> SPRING.
>
> Any help would be greatly appreciated. Thanks.
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog