public static JAXBElement createJAXBelement(Object content) { Class clazz = (Class) content.getClass(); // Remove the 'Type' suffix from the xml type name and use it as XML element! XmlType t = (XmlType) clazz.getAnnotation(XmlType.class); String element = t.name().substring(0, t.name().length() - 4); return new JAXBElement(new QName(JossoConstants.JOSSO_PROTOCOL_NS, element), clazz, content); }