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]>

Reply via email to