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 Gustavo De Simone <gu...@montevideo.com.uy> on 2004/07/05 17:44:07 UTC

Re: Transient member serializaton

IF you don't want to If  Person is a Bean this might work...
Create a class named PersonBeanInfo in the same package as Person with the
next content...I 've used this in Axis 1.1 and it works I assume that will
work in Axis 1.2 either.

public class PersonaBeanInfo extends SimpleBeanInfo{

    public PropertyDescriptor[] getPropertyDescriptors() {
        PropertyDescriptor[] p = new PropertyDescriptor[2];
        try {
            //using only this properties you ...
            p[0]= new PropertyDescriptor("name",Person.class);
            p[1]= new PropertyDescriptor("phone",Person.class);
        } catch (IntrospectionException e) {
            e.printStackTrace();
        }
        return p;
    }

    //If Person extends from Animal and you need to do the same with Animal
then
    //create AnimalBeanInfo and this method too...
       public BeanInfo[] getAdditionalBeanInfo() {
        return new BeanInfo[]{new AnimalBeanInfo()};
    }

}

All these things are related with the JavaBeans specification and jaxrpc
specification...

----- Original Message -----
From: "EXT / ALTIOR KAH Antoine (DR&T)" <ex...@sncf.fr>
To: <ax...@ws.apache.org>
Sent: Monday, June 28, 2004 5:40 AM
Subject: RE: Transient member serializaton


Have you tried setting the id member private ?

-----Message d'origine-----
De : Galkovsky Michael [mailto:galkovsky_michael@bah.com]
Envoyé : vendredi 25 juin 2004 20:44
À : axis-user@ws.apache.org
Objet : Transient member serializaton


Hi,
I am kind of in a bind.  We are using Axis 1.2 and have a number of
beans that have some transient members that we do not want to be
serialized over the wire.  I can't figure out a way to do this.  Imagine
a bean that has 3 members

Person
   id
   name
   phone


And my service, getAllPersons, should return just the name
and phone, since id is an internal data and has no relevance to the
consumer.

My Person class was generated by Wsdl2Java, in wsdl I only describe name
and phone, id is not metioned.  The generated person.java did not have
any reference to id until i added it just to the java class after it was
generated.

Now the id member gets serialized along with name and phone. Even though
the typeDesc does not mention it.

Now whenever I get my person object in the web service client I get an
error because the id is serialized and naturally an error is thrown.

I traced the code as far down into axis as I could to try to figure out
why BeanSerializer was using reflection and not the typeDesc that the
Person class returned to it.

Any insight would be much appreciated.  Thanks in advance.

Michael