You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Christoph Gaffga <cg...@triplemind.com> on 2003/08/18 20:03:20 UTC

serialize a Bean with Axis

Hi,
I have a very simple test Bean, I want to serialize to System.out. Is this
possible?

I tried it like this:

      QName qname = new QName("TestXMLSerializerQName");
      AttributesImpl attr = new AttributesImpl();
      PrintWriter writer = new java.io.PrintWriter(System.out);

      SerializationContextImpl ctx = new SerializationContextImpl(writer);
      ctx.setSendDecl(true);
      ctx.setPretty(true);

      ctx.serialize(qname, attr, new Integer(22));
      ctx.serialize(qname, attr, this);

      writer.close();

I get

<?xml version="1.0" encoding="UTF-8"?>
<TestXMLSerializerQName xsi:type="xsd:int"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">22</TestXMLSerializerQName>

without the "ctx.serialize(qname, attr, this);"-line. Otherwise I get:

java.io.IOException: No serializer found for class
com.triplemind.samples.TestXMLSerializer in registry
org.apache.axis.encoding.DefaultTypeMappingImpl@ecb281

What to do to avaid this exception?

Regards
Christoph

P.S.: Didn't found anything on the list, perheaps I missed it.