try {
XMLStreamWriter xmlStreamWriter = createStreamWriter(aegisType.getSchemaType(), 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 new WebApplicationException(e);
}
}