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 Mitch Gitman <mg...@usa.net> on 2002/12/03 02:44:24 UTC
deserializing nested complex types
I had come to realize (perhaps mistakenly) that I needed to use a custom
serializer/deserializer for a complex type that had another JavaBean
complex type as an element inside it. You see, when my test Axis client was
querying the server, it was generating a fault with a stackTrace that began:
org.xml.sax.SAXException: SimpleDeserializer encountered a child element,
which is NOT expected, in something it was trying to deserialize.
at
org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:187)
So I proceeded to replace BeanSerializer/BeanDeserializer with custom
serialization. Here's the updated typeMapping in server-config.wsdd:
<typeMapping
deserializer="foo.bar.axis.SomethingDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns40:Something"
serializer="foo.bar.axis.SomethingSerializerFactory"
type="java:foo.bar.Something" xmlns:ns40="urn:bar.foo" />
As you can see, besides the SomethingSerializer and SomethingDeserializer
classes, there is a factory class for each.
Now for a simple test, I have my client call:
Something addSomething(String data)
The call appears to have been put together correctly on the client side.
That includes registering the type mapping. The call reaches the server
and, as far as I can tell, server execution proceeds as follows:
1. Calls the SomethingDeserializerFactory constructor.
2. Throws the same exception I encountered earlier with the default
serialization. "SimpleDeserializer encountered a child element,..."
This fault occurs BEFORE:
* The factory can return a new SomethingDeserializer through its
getDeserializerAs(String mechanismType).
* My application code -- namely addSomething() itself -- can be reached.
Perhaps someone can offer a working example of how to nest inside a complex
type what is essentially another complex type.
Re: deserializing nested complex types
Posted by Mitch Gitman <mg...@usa.net>.
Minor point aside from the larger issue of plugging in custom
deserialization. I notice that the Axis framework instantiates my custom
deserializer factory but then, rather than asking the factory for a custom
deserializer, just goes ahead and uses SimplerDeserializer anyway.
At 17:44 02.12.02 -0800, I wrote:
>I had come to realize (perhaps mistakenly) that I needed to use a custom
>serializer/deserializer for a complex type that had another JavaBean
>complex type as an element inside it. You see, when my test Axis client
>was querying the server, it was generating a fault with a stackTrace that
>began:
>org.xml.sax.SAXException: SimpleDeserializer encountered a child element,
>which is NOT expected, in something it was trying to deserialize.
> at
> org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:187)
>
>So I proceeded to replace BeanSerializer/BeanDeserializer with custom
>serialization. Here's the updated typeMapping in server-config.wsdd:
><typeMapping
>deserializer="foo.bar.axis.SomethingDeserializerFactory"
>encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>qname="ns40:Something"
>serializer="foo.bar.axis.SomethingSerializerFactory"
>type="java:foo.bar.Something" xmlns:ns40="urn:bar.foo" />
>
>As you can see, besides the SomethingSerializer and SomethingDeserializer
>classes, there is a factory class for each.
>
>Now for a simple test, I have my client call:
>Something addSomething(String data)
>
>The call appears to have been put together correctly on the client side.
>That includes registering the type mapping. The call reaches the server
>and, as far as I can tell, server execution proceeds as follows:
>1. Calls the SomethingDeserializerFactory constructor.
>2. Throws the same exception I encountered earlier with the default
>serialization. "SimpleDeserializer encountered a child element,..."
>
>This fault occurs BEFORE:
>* The factory can return a new SomethingDeserializer through its
>getDeserializerAs(String mechanismType).
>* My application code -- namely addSomething() itself -- can be reached.
>
>Perhaps someone can offer a working example of how to nest inside a
>complex type what is essentially another complex type.
>