Fields are not part of a JavaBean spec. The BeanSerializer does not serialize them by design.
There may be some circular reasoning going on here. If you did de-serialize the public final fields, then the fields in the client object would have to be mutable. If that was the case, than in *any* case, the client could override what you send over the wire. SOAP provides a way to access an object's interface, high level. It is not designed to send the implementation over the wire. That is why things like fields are left out by the BeanSerializer. If these were serialized, the SOAP packet would be terribly complex, and it would cease to be SOAP (Simple Object ...). Ben On Thu, 2003-02-06 at 16:31, Liviu Chiriac wrote: > > I am using the BeanDeserializer. I am just trying to avoid to have to > write my own deserializer. I think the BeanSerializer should serialize > my constants because otherwise the client does NOT get them. (as far as > I can conclude from my testing...) > > If I write go with the interface as you said, the BeanDeserializer will > create setters/getters for the non-final Strings in the ComplexObject, > right? And then the client can even change their values on the client > side ?! > > Liviu > > -----Original Message----- > From: Mike Burati [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 4:07 PM > To: 'Liviu Chiriac'; [EMAIL PROTECTED] > Subject: RE: how to serialize/deserialize static final fields > > > Ah, mistakenly thought you were in control of the client too and either > using a custom deserializer or trying to map your ComplexObject class > via a > BeanDeserializer... Using code generated from WSDL is another story > altogether... > > You could add another method which returns a list of valid names that > the > client can call, but that's adding the overhead of another operation... > > If "final" turns out to be the only blocker, then you could try defining > the > final string constants in another class (eg, a Java Interface > StringConstants class) and have your class implement that constants > interface and then have non-final Strings that map to the constants. > > ..Mike > > > -----Original Message----- > From: Liviu Chiriac [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 4:01 PM > To: [EMAIL PROTECTED] > Cc: 'Mike Burati' > Subject: RE: how to serialize/deserialize static final fields > > > No, they are not going to be the same on both ends. > > >From what I gather: > The client creates its class using the WSDL. Because these constants > do not get serialized, they are not mentioned in WSDL. Since they are > never mentioned in the WDSL, the client creates a class without them The > client does not have the same class I am using on the server. > > So ... If I expect him to set something (like the 'name' in my example) > to one of these constants, he can't because he does not have them. > > Liviu > > -----Original Message----- > From: Mike Burati [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 3:29 PM > To: '[EMAIL PROTECTED]' > Subject: RE: how to serialize/deserialize static final fields > > > You lost me - if you're using the ComplexObject class on both ends of > the > connection and those string constants are final, then why would you ever > want them serialized/sent/deserialized? They're gonna be the same on > both > ends of the connection anyway? > > -----Original Message----- > From: Liviu Chiriac [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 2:59 PM > To: [EMAIL PROTECTED] > Subject: RE: how to serialize/deserialize static final fields > > > > Even if they are not 'static' and only 'final' .... it does not work!! > > Liviu > > > -----Original Message----- > From: Zhaohua Meng [mailto:[EMAIL PROTECTED]] > Sent: Thursday, February 06, 2003 2:04 PM > To: [EMAIL PROTECTED] > Subject: Re: how to serialize/deserialize static final fields > > By definition static variables are not serializable. You need to write > your own se/deserializer. I am trying to figure out a way to do the same > > thing to my application. Once figured out, I will drop some lines here. > Liviu Chiriac wrote: > > > > > > Say that I have a Web Service that sends the client a ComplexObject. > The > > client needs to return it back after setting its name to either > > ComplexObject.NAME1, ComplexObject.NAME2 or ComplexObject.NAME3 > (static > > final fields - constants) > > > > > > > > The problem is that the static final fields never get > > serialized/deserialized by the BeanSerializer. > > > > > > > > Is this a bug, or intended behavior? If intended behavior, what is an > > elegant way of doing it? > > > > > > > > -------------------------------------- > > > > public class ComplexObject implements java.io.Serializable { > > > > public static final String NAME1 = "name1"; > > > > public static final String NAME2 = "name2"; > > > > public static final String NAME3 = "name3"; > > > > > > > > private name; > > > > public void setName(String s) { > > > > name = s; > > > > } > > > > public String getName() { > > > > return name; > > > > } > > > > } > > > > -------------------------------------- > > > > > > > > > > > >