hi:

    I also want to know the answer that how I can serialize and deserialize the

arrays of nested beans?

   So would you please send some code to me? or post them here?

 

  Thanks

 

 

 

 Benjamin Tomasini <[EMAIL PROTECTED]> wrote:

I too converted my collections to arrays and found that it worked well.
I would also be curious to know why the standard (de)serializers
wouldn't work. I have been using beans and arrays of nested beans
without any trouble, and without needing the custom stuff.

If you want to satisfy your curiosity, you could always submit your
sources with their deployment descriptors here. I am sure someone would
know the answer.

It is possible that you are getting the ClassCastException with your
toArray method, and it is unrelated to Axis. I would test this by
replacing the body of the get method with a statement that returned a
dummy array, with one element.

Take care,

Ben Tomasini

On Wed, 2002-12-11 at 23:07, Mitch Gitman wrote:
> I have a similar requirement. I need a class that contains an array of
> another class. Like Mr. Tomasini advised, I hid the member variable for the
> array and instead used a public getter and setter. Here are the relevant
> methods for the class, which I'll refer to here as Parent:
> public Child[] getChildrenAsArray() {
> ____Collection all = getValuesHelper();
> ____return (Child[])all.toArray(new Child[all.size()]);
> }
>
> /** Dummy method used just for bean compliance */
> public void setChildrenAsArray(Child[] ideasArray) { }
>
> I was not able to make the regular bean (de)serializer work for the parent
> class. So I resorted to using a custom (de)serializer. This is not to
> generalize that the bean (de)serializer can't work; I've seen someone
> else's web service work in this same circumstance. While I might as well
> stick with what's working for me, I would be curious why the default does not.
>
> Here's the error I always get with the bean (de)serializer:
> AxisFault
> faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
> faultSubcode:
> faultString: java.io.IOException: java.lang.ClassCastException:
> [Ljava.lang.Object;
> faultActor: null
> faultNode: null
> faultDetail:
> stackTrace: java.io.IOException: java.lang.ClassCastException:
> [Ljava.lang.Object;
> at
> org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:261)
> ...
>
> To turn on the custom serialization, I had go into deploy.wsdd (which is
> used to generate server-config.wsdd) and manually change the typeMapping
> element's (de)serializer attributes. Here's the changed element:
> > type="java:foo.bar.Parent"
> serializer="foo.bar.axis.ParentSerializerFactory"
> deserializer="foo.bar.axis.ParentDeserializerFactory"
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
>
> I wrote the (de)serializer classes and their respective factories based on
> examples from the book "AXIS: The Next Generation of Java SOAP," published
> by Wrox Press. The book's a little out-of-date already, so I had to update
> the method signatures slightly.
>
> Now when I run a test Axis client against an Axis server, the Parent data
> structure is serialized, sent and deserialized correctly, with zero, one or
> more children in the array. However, I'm not sure if the Axis client is
> truly using the custom deserializer and not BeanDeserializer.
>
> At 22:18 10.12.02 -0500, you wrote:
> >I would make T ... T3 into java beans (private members with
> >corresponding public getters and setters). If you can't do that, wrap
> >them with classes that are. Axis will have a hard time with your
> >classes becuase they are public instance variables.
> >
> >You could write your own serializers, but that would be lots of work.
> >
> >Very compelx things can genrally be done with ease if you stick with
> >these conventions.
> >
> >Ben Tomasini
> >
> >
> >
> >On Tue, 2002-12-10 at 22:17, Dongsheng Song wrote:
> > > I use a very complex type for soap, Please Help me modify my
> > deploy.wsdd file:
> > >
> > > > > > xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
> > >
> > >
> > >
> > >
> > >
> > >
> > > > > > xmlns:ns="http://soapinterop.org/xsd"
> > > qname="ns:T"
> > > type="java:T"
> > > serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
> > > deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
> > > encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> > > />
> > >

> > >
> > >

> > >
> > > public class EnterUp
> > > {
> > > public String register(T info)
> > > {
> > > }
> > > }
> > >
> > > public class T implements java.io.Serializable{
> > > public T2 fd;
> > > public T3[] fd2;
> > > }
> > >
> > > public class T2 implements java.io.Serializable{
> > > public String fd;
> > > public String fd2;
> > > }
> > >
> > > public class T3 implements java.io.Serializable{
> > > public String fd;
> > > public String fd2;
> > > }
> > >
> > > furthermore, is ther a java2wsdd tool ?
>



Post your free ad now! Yahoo! Canada Personals

Reply via email to