On Oct 11, 2012, at 10:30 AM, rouble <[email protected]> wrote: > Thats an interesting way to do it. Just to be clear you want me to > save some text in afterUnmarshal() into the CXF Message exchange and > come back in an interceptor to pick up that text and set it. > > Thinking out loud of another way, is it possible to access all the > input beans in an interceptor after the UNMARSHAL phase? That way I > can do my validation in that interceptor and throw an exception from > there. Let me know if there is a way to do this?
Yep. The USER_LOGICAL phase is designed specifically for this. If you do a message.getContent(List.class), you should get back a list of the unmarshalled objects that you can then validate. > Also - do you kow why is it not possible to set the error code in the > exception from afterUnmarshall() - is that just a deficiency in the > system? Should we have a jira for this? If you can create a small test case, we can look at it. It may be a deficiency in JAXB though. JAXB tends to catch exceptions and pass them into various error handlers that may then throw a completely different exception. I've seen that in a couple instances. Dan > > tia, > rouble > > On Wed, Oct 10, 2012 at 9:11 PM, Freeman Fang <[email protected]> wrote: >> Hi, >> >> You can save the message whatever you want to the cxf Message/Exchange, and >> then add another interceptor for the OutFaultChain(at the very beginning), >> where you can get the exception by means like >> message.getContent(Exception.class) >> You can modify this exception and set any cause text you saved before >> ------------- >> Freeman Fang >> >> Red Hat, Inc. >> FuseSource is now part of Red Hat >> Web: http://fusesource.com | http://www.redhat.com/ >> Twitter: freemanfang >> Blog: http://freemanfang.blogspot.com >> http://blog.sina.com.cn/u/1473905042 >> weibo: http://weibo.com/u/1473905042 >> >> On 2012-10-11, at 上午4:45, rouble wrote: >> >>> CXF Gurus, >>> >>> We were looking into using the afterUnmarshal(Unmarshaller, Object >>> parent) method to validate data beans. This works well, except we >>> can't seem to send back a meaningful exception. We tried throwing a >>> new UnmarshallException("Some text", "Some other text") but it does >>> not matter what we throw inside afterUnmarshall it always looks like >>> this on the client: >>> <soap:Fault> >>> <faultcode>soap:Client</faultcode> >>> <faultstring>Unmarshalling Error: null </faultstring> >>> </soap:Fault> >>> >>> Is it possible to throw a meaningful exception that will get properly >>> unmarshalled into XML/text to the client? We want to be able to tell >>> the client something like: "Field ABC is mandatory". >>> >>> Note here that we tried to enable schema validation to do this >>> validation for us but that has some drawbacks which I won't get into >>> for now. >>> >>> tia, >>> rouble >> -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
