I'm trying to fix what I think is a small bug in Aegis, having to do with unmarshaling Maps. I'm inconvenienced by having to use a web service to supply the marshaled data for my experimentation. What I'd like is a bare-bones way to call some method, passing it an arbitrary object (neither a basic type nor an extension of BeanType) and having it return a String of the Aegis-serialized object. I have looked at BeanTest.java and StandaloneWriteTest.java, but neither of them seems to have code to do what I just described. Unmarhaling, btw, seems to be simple; the following code works for me:
private Object unmarshal(String xml) throws Exception { AegisContext context = new AegisContext(); // I'm actually using an extension of AegisContext, so this is a white lie context.initialize(); XMLStreamReader xmlReader = xmlInputFactory.createXMLStreamReader(new StringReader(xml)); AegisReader<XMLStreamReader> reader = context.createXMLStreamReader(); return reader.read(xmlReader); } For marshaling I've tried any way I could think of, but to no avail. Here's one example that doesn't work, for reasons that are unclear to me: private String marshal(Object obj, String msg) throws Exception { StringWriter stringWriter = new StringWriter(); XMLStreamWriter xmlWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter); MessageWriter mw = new ElementWriter(xmlWriter); BeanType type = new BeanType(); type.setTypeClass(obj.getClass()); type.setTypeMapping(context.getTypeMapping()); type.setSchemaType(new QName("http://" + obj.getClass().getPackage().getName(), obj.getClass().getSimpleName())); type.writeObject(obj, mw, new Context(context)); xmlWriter.close(); return stringWriter.toString(); } I'd appreciate any help, but mostly I'd appreciate seeing the few lines of code that I imagine are all it would take to implement my marshal() method. Thanks in advance. Michael