Exception ex = (Exception)cause;
Object bean = getFaultBean(cause, fi, message);
Service service = message.getExchange().get(Service.class);
MessagePartInfo part = fi.getMessageParts().iterator().next();
DataBinding db = service.getDataBinding();
try {
if (isDOMSupported(db)) {
DataWriter<Node> writer = db.createWriter(Node.class);
if (f.hasDetails()) {
writer.write(bean, part, f.getDetail());
} else {
writer.write(bean, part, f.getOrCreateDetail());
if (!f.getDetail().hasChildNodes()) {
f.setDetail(null);
}
}
} else {
if (f.hasDetails()) {
XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getDetail());
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
writer.write(bean, part, xsw);
} else {
XMLStreamWriter xsw = new W3CDOMStreamWriter(f.getOrCreateDetail());
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
writer.write(bean, part, xsw);
if (!f.getDetail().hasChildNodes()) {
f.setDetail(null);
}
}