Willem, here is the code for addSoapFault(exchange, new CantTalkFault_Exception("Ups", cantTalkFault));
I am using it with cxf PAYLOAD data format. public static void addSoapFault(Exchange exchange, Exception faultException) throws Exception { if (!faultException.getClass().isAnnotationPresent(WebFault.class)) { throw new IllegalArgumentException("Exception argument should represent @WebFault"); } Object faultInfo = null; try { faultInfo = getFaultInfo(faultException); } catch (Exception e) { throw new IllegalArgumentException("Exception argument doesn't have a getFaultInfo method"); } SoapFault soapFault = new SoapFault(faultException.getMessage(), new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server")); if (faultInfo != null) { soapFault.setDetail(marshalDetails(faultException, faultInfo)); } exchange.getOut().setBody(soapFault); exchange.getOut().setFault(true); } private static Element marshalDetails(Exception faultException, Object faultInfo) throws Exception { WebFault webFault = faultException.getClass().getAnnotation(WebFault.class); JAXBContext context = JAXBContext.newInstance(faultInfo.getClass()); Element detail = DOMUtils.readXml(new StringReader("<detail></detail>")).getDocumentElement(); QName qname = new QName(webFault.targetNamespace(), webFault.name()); JAXBElement jaxbElement = new JAXBElement(qname, faultInfo.getClass(), getFaultInfo(faultException)); context.createMarshaller().marshal(jaxbElement, detail); return detail; } private static Object getFaultInfo(Exception exception) throws Exception { Method method = exception.getClass().getMethod("getFaultInfo"); return method.invoke(exception); } -- View this message in context: http://camel.465427.n5.nabble.com/Help-with-nmr-cxf-endpoints-and-fault-handling-tp5719720p5720293.html Sent from the Camel - Users mailing list archive at Nabble.com.