AegisWriter<XMLStreamWriter> aegisWriter = context.createXMLStreamWriter();
try {
String enc = HttpUtils.getSetEncoding(m, headers, "UTF-8");
XMLStreamWriter xmlStreamWriter = createStreamWriter(aegisType.getSchemaType(), enc, os);
// use type qname as element qname?
xmlStreamWriter.writeStartDocument();
aegisWriter.write(obj, aegisType.getSchemaType(), false, xmlStreamWriter, aegisType);
xmlStreamWriter.writeEndDocument();
xmlStreamWriter.close();
} catch (Exception e) {
throw ExceptionUtils.toInternalServerErrorException(e, null);