Hi Henrik I reckon looking at the wire representation would really help in figuring out what's going on. Also, can it be that say the XStream writer needs to have some kind of close() method being called ?
Please send a wget/browser request through a tcp trace utility and let me know the details Thanks, Sergey -----Original Message----- From: Henrik Martin [mailto:[email protected]] Sent: 03 November 2009 22:03 To: [email protected] Subject: Re: Would like to send custom XML back whenever a 400 or 500 category error happens Sergey, thanks for the response. I should have given you a little more detail. In my handleResponse() method, I do return a Response, which contains something similar to your suggested ExceptionInfo. It's just a Java bean containing some properties and some XStream annotations. When I run everything in the debugger, I can see that my entity (containing the exception information) gets handled by our MessageWriter, and proper XML gets generated (I'm printing it out inside the MessageWriter). This is what's puzzling me, I never see the XML after that. I don't get any exceptions being thrown anywhere, so I don't think it's a failure of any kind. Our MessageWriter is registered to handle any type thrown at it. It basically uses XStream to stream out the beans into XML. It seems to work fine. If I set the HTTP status code to 200 and return the exact same exception data, it gets streamed out properly all the way back to the client. I'm curious to what the difference is in execution path when I'm setting the HTTP status to a 400 or 500? I've tried following along in the debugger, but there are so many levels of calls that it's a little overwhelming. Is there some sort of error handler in the CXF framework that takes different paths depending on the value of the HTTP status code? Thanks, /Henrik On Mon, 2009-11-02 at 17:11 -0500, Sergey Beryozkin wrote: > Hi Henrik > > > > For some reasons I can only see your message in Archives, but not > Nabble. > > > > >>The handleResponse() method in > >>my filter gets called, but I've found that if I return any kind of > >>error, i.e. a category 400 or 500 type error, the XML that I'm > returning > >>as the content doesn't get rendered in the browser > > If one returns a custom Response from a filter, then its entity, if any, > will be > serialized by the available writers. > > So if you set a String instance as a custom entity and you happen to > have a custom message body writer which can > wrap Strings then the browser would show it as a plain text sequence. > > Starting from CXF 2.2.4 it is possible to indicate that writers have to > be ignored. In meantime, the best way would be to return > an object like ExceptionInfo which will be serialized by the appropriate > XML writer. > > Is it what might be happening in your case ? > > If you're thinking of doing JAXRS only then filters should do well. > > Cheers, Sergey > > > > > > > > > >
