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 David Scheck <ds...@apple.com> on 2004/01/31 07:18:31 UTC

How can I morph a Java array to a Vector subclass during serial/deserialization?

I have a server that sends custom objects over SOAP that include Java
arrays of other custom objects.

public class Category  {
	public String name;
	public Category[] subCategories;
	public Category parent;
	public User[] owners;

	public Category() {
	}
         ...

I have the client and sever app working fine but, in another special
client app I need to  figure out how to deserialize the java arrays to
look like a java class instead.  I also will need to serialize the Java
class back into xml that looks like a normal Java array for the server.

(I need to do this because of some language bridging stuff I am doing
from Java to ObjC, and the bridge does not support Java arrays as
needed)

So, my thought was that I needed to create a subclass of Vector for
every Java array I know I might see.  Then I need to figure out how to
setup the mappings and write a deserializer/serializer from this Vector
subclass.

public class Category  {
	public String name;
	public ArrayOfCategory subCategories;
	public Category parent;
	public ArrayOfUser owners;

	public Category() {
	}
         ...


public class ArrayOfCategory: Vector {

}

I imagine I need to write the following other classes:  (anyone want to
help me with these?)

ArrayOfCategorySerializer
ArrayOfCategorySerializerFactory
ArrayOfCategoryDeserializer
ArrayOfCategoryDeserializerFactory

(and the same as well for ArrayOfUser)

Now, how do I tell the client axis code that when it sees a serialized
Category[] from the server that it should use my
ArrayOfCategoryDeserializer to that I get a proper instance of
ArrayOfCategory instead of a Category[]?

And, how do I tell the client axis code that when it is serializing an
ArrayOfCategory object that to needs to use my
ArrayOfCategorySerializer to write XML that the server will
recognize as a normal Category[] ?

How do I tweak the generated files from WSDL2Java that have all the
Category[] in them so that they now have ArrayOfCategory?

Would it be better to somehow create faked out wsdl so that the 
generation
creates ArrayOfCategory in the first place?

Anyone want to show me the wsdl I need?

Your help is greatly appreciated!

dave