message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
NSStack nsStack = new NSStack();
nsStack.push();
XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
XMLFault xmlFault = XMLFault.createFault(f);
try {
nsStack.add(XMLConstants.NS_XML_FORMAT);
String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT);
StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT,
XMLConstants.NS_XML_FORMAT);
StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING,
XMLConstants.NS_XML_FORMAT);
Throwable t = xmlFault.getCause();
writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
// fault string
writer.writeEndElement();
// call StaxUtils to write Fault detail.
if (xmlFault.getDetail() != null) {
StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
XMLConstants.NS_XML_FORMAT);
StaxUtils.writeNode(DOMUtils.getChild(xmlFault.getDetail(), Node.ELEMENT_NODE),
writer, false);
writer.writeEndElement();
}
// fault root
writer.writeEndElement();