try {
XMLStreamWriter writer = getWriter(message);
Fault fault = getFault(message);
NMRFault jbiFault = NMRFault.createFault(fault);
nsStack.add(NMRConstants.NS_NMR_BINDING);
String prefix = nsStack.getPrefix(NMRConstants.NS_NMR_BINDING);
StaxUtils.writeStartElement(writer, prefix, NMRFault.NMR_FAULT_ROOT,
NMRConstants.NS_NMR_BINDING);
if (!jbiFault.hasDetails()) {
writer.writeEmptyElement("fault");
} else {
Element detail = jbiFault.getDetail();
NodeList details = detail.getChildNodes();
for (int i = 0; i < details.getLength(); i++) {
if (details.item(i) instanceof Element) {
StaxUtils.writeNode(details.item(i), writer, true);
break;