public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault {
try {
XFireFault fault = (XFireFault) message.getBody();
if (fault.hasDetails()) {
Element detail = fault.getDetail();
StaxSerializer serializer = new StaxSerializer();
List details = detail.getContent();
for (int i = 0; i < details.size(); i++) {
serializer.writeElement((Element) details.get(i), writer);
}
} else {
writer.writeStartElement("stack");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);