Chris, It is up to you when you define your mappings and/or write your serializers whether the classes implementing interfaces will be serialized with just information for the interface or for the actual class. I personally prefer to have separate mappings for each concrete class. I don't like to have one serializer for an interface that internally actually knows how to serialize each class that implements the interface. Big switch statements or multiple if/else branches don't feel right to me in the O-O world.
Anyway, in your case this means I would write serializers (and deserializers) for SimpleData and ComplexData, then map each type to the corresponding [de-]serializer. The server will correctly resolve these types as parameters to the doSomething method. Scott Nichol ----- Original Message ----- From: "Chris Kelly" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 01, 2002 7:48 PM Subject: passing interfaces instead of classes > Consider: > > interface IData { > int getValue(); > } > > class SimpleData implements IData { > int value; > public SimpleData( int v ) { value = v; } > public int getValue() { return value; } > } > > class ComplexData implements IData { > float value, multiplier; > public SimpleData( float v, float m; ) { > value = v; > multiplier = m; > } > public int getValue() { > return (int) ( multiplier * value ); > } > } > > Then, consider a service that accepts an IData object: > > class SoapService { > public doSomething( IData data ) {...} > } > > If I pass an IData object in a bean-like fashion, only the 'value' will be > sent in the XML, not the 'multiplier' if the IData object I'm sending is a > ComplexData object. > > If I change SoapService.doSomething to accept either a SimpleData or a > ComplexData, then the other class can't be sent. > > So, am I missing something, or is it difficult to represent passed objects > as interfaces? Must they be represented as classes? > > One way around this would be to pass IData objects as the name in the XML, > and include the name of the implementing class in the XML as well. An IData > de/serializer would then determine the implementing class, and call a > de/serializer specific to that implementing class. Is there an automatic > way to do this? > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>