JAX-WS and abstract classes in a complex type

Hi,

i'd like to have to following behaviour:

@WebMethod

publicint testMethod(ComplexType ct){

return ct.getProcessor().do(5,5);

}

///

publicclass ComplexType{

Processor p;// + getter + setter ...

}

publicabstractclass Processor{

publicintdo(int a,int b){}

}

publicclass ProcessorA{

publicintdo(int a,int b){

return a+b;

}

}

publicclass ProcessorB{

publicintdo(int a,int b){

return a*b;

}

}

//

// ...

ctA.p =new ProcessorA();

ctB.p =new ProcessorB();

port.testMethod(ctA);// = 10

port.testMethod(ctB);// = 25

--

But the wsimport tool does only generate stub classes for Processor and not for the subclasses, even if i use jax-ws & jaxb 2.1 and apply a @XmlSeeAlso tag in front of the Processor class. The result is that ctX.p = new ProcessorX() is not possible.

Thanks in advance

[2664 byte] By [sebbera] at [2007-11-27 7:56:36]
# 1

If you use JAX-WS 2.1.1, you can place an @XmlSeeAlso annotation on the SEI with all of the concrete classes that you will to use. You can look at the type_substitution sample to see how to do this.

@WebService(name="CarDealer")

@XmlSeeAlso({Car.class, Toyota.class})

public class CarDealer {

public Car tradeIn(Car oldCar){

if(!(oldCar instanceof Toyota))

throw new WebServiceException("Expected Toyota, received, "+oldCar.getClass().getName());

Toyota toyota = (Toyota)oldCar;

if(toyota.getMake().equals("Toyota") && toyota.getModel().equals("Avalon") && toyota.getYear().equals("1999") && toyota.getColor().equals("white")){

return new Toyota("Avalon", "2007", "black");

}

throw new WebServiceException("Invalid Toyota Car");

}

...

}

dkohlerta at 2007-7-12 19:38:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...