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:
<typeMapping xmlns:ns="urn:bar.foo" qname="ns:Parent" 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:
>
> <deployment xmlns="http://xml.apache.org/axis/wsdd/";
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
>
> <service name="EnterUp" provider="java:RPC">
>
> <parameter name="className" value="EnterUp"/>
> <parameter name="allowedMethods" value="*"/>
>
> <typeMapping
> 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/";
> />
> </service>
>
> </deployment>
>
> 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 ?


Reply via email to