Hello,

For some reasons, I try using the FlexFaultResponseInterceptor but it does
not
work. The returned http status is still 500 instead of 200. I hope someone
can shed more light into this. Below are the steps taken:

(1) tomcat v6.0.20 

     This is the servet to host the apache cxf webservice.

(2) applicationContext.xml

        <bean id="faultInterceptor"
                class="com.xxx.FlexFaultResponseInterceptor" />

        <jaxws:endpoint address="/services/Test">
                <jaxws:implementor>
                        <bean class="com.xxx.TestImpl"/>
                </jaxws:implementor>
                <jaxws:outFaultInterceptors>
                        <ref bean="faultInterceptor" />
                </jaxws:outFaultInterceptors>
        </jaxws:endpoint>

(3) FlexFaultResponseInterceptor.java

        public class FlexFaultResponseInterceptor extends
                AbstractPhaseInterceptor<Message>
        {
            protected Log log = LogFactory.getLog(getClass());

            public FlexFaultResponseInterceptor()
            {
                super(Phase.POST_PROTOCOL);
            }

            public void handleMessage(Message message) throws Fault
            {
                Message in = message.getExchange().getInMessage();
                Map<String, Object> headers = (Map<String, Object>)
in.get(Message.PROTOCOL_HEADERS);

                log.info("(a) message=" +
InterceptorUtility.toString(message));

                Object version = headers.get("x-flash-version");
                if (version != null)
                {
                    message.remove(Message.RESPONSE_CODE);
                    message.put(Message.RESPONSE_CODE, new Integer(200));
                }

                log.info("(b) message=" +
InterceptorUtility.toString(message));
            }
        }

(4) log4j.log

     When flex client made a call to the webservice, the following log
traces are captured. Notice
     that the code actually set the RESPONSE_CODE to 200 but the returned
http status is still 500.
     

08/05/2009 11:08:08 INFO
(FlexFaultResponseInterceptor.java:44:handleMessage) - (a) message=

 http.response=org.apache.catalina.connector.responsefac...@19ff66f
 org.apache.cxf.message.FaultMode=CHECKED_APPLICATION_FAULT
 wrote.envelope.start=true
 org.apache.cxf.message.Message.PROTOCOL_HEADERS={}
 Content-Type=text/xml
 org.apache.cxf.message.Message.ENCODING=UTF-8
 org.apache.cxf.message.Message.RESPONSE_CODE=500
08/05/2009 11:08:08 INFO
(FlexFaultResponseInterceptor.java:60:handleMessage) - (b) message=

 http.response=org.apache.catalina.connector.responsefac...@19ff66f
 org.apache.cxf.message.FaultMode=CHECKED_APPLICATION_FAULT
 wrote.envelope.start=true
 org.apache.cxf.message.Message.PROTOCOL_HEADERS={}
 Content-Type=text/xml
 org.apache.cxf.message.Message.RESPONSE_CODE=200
 org.apache.cxf.message.Message.ENCODING=UTF-8

(5) axis-monitor

     I use axis-monitor to capture the request/response between flex client
and apache cxf webservice.
     The following response is captured below. Notice that http/1.1 500 is
sent back to the flex client. Also
     notice that the faultstring and faultcode within the soap emvelope is
correctly set by TestImpl.java 

HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=UTF-8
Content-Length: 442
Date: Wed, 05 Aug 2009 15:10:29 GMT
Connection: close

<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>This
is from test().</faultstring><detail><ns2:ServiceException
xmlns:ns2="http://xxx.com/";><actor>com.xxx.TestImpl.test()</actor><code>1020</code></ns2:ServiceException></detail></soap:Fault></soap:Body></soap:Envelope>


Thanks,
Khai Wan
-- 
View this message in context: 
http://www.nabble.com/CXF-Fault-Response-Code-tp22874000p24829977.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to