You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Levy, Avi" <av...@dor.state.wi.us> on 2004/11/22 21:42:20 UTC
Using a serializer and deserializer
Hi,
I'm new to Axis.
I used wsdl2java to generate code for my wsdl.
I would like to be able to read/write my java objects from/to xml files so I
can run tests and compare XML that being sent and received.
Is it possible to use the Serializer and Deserializer to do that?
If yes, how would the code look like?
Is there any tutorials about it somewhere?
Any help would be greatly appreciated.
Thanks,
-- AV
Re: Using a serializer and deserializer
Posted by toby cabot <to...@caboteria.org>.
Don't know about any docs or tutorials but something like...
void axisSerialize(Object report, Writer whereTo) throws IOException {
SerializationContext ser = new SerializationContext(whereTo);
ser.setPretty(true);
ser.setSendDecl(true);
AttributesImpl ns = new AttributesImpl();
// add attributes here
ser.serialize(new QName("elementName"), ns, report, null, Boolean.FALSE, Boolean.FALSE);
whereTo.flush();
}
... should get you pretty close. Make sure that you're using the
latest and greatest Axis as there have been a few bugs fixed recently.