5 Replies Latest reply on Mar 27, 2009 3:01 PM by Alessio Soldano

    Problem with inheritance - JbossWS

    Mats Ekström Newbie

      I have problem to get inheritance in a WS to work.
      I've tried a small example on these env:
      Windows XP SP2
      Jboss AS 4.2.2 GA , 4.2.3 (and also JBoss eap 4.3)

      I'm trying to do a request to server with a parameter that contains a inherited class. Class testEnv contains class testAAA, and class testBBB inherits testAAA. So when I put testBBB in testEnv and sends it to the WS I'm supposed to get testBBB from testEnv on the server - but I only get a testAAA!

      Classes used in my example:

      public interface TestWS {
       public String test(TestEnv testEnv);
      @WebService(name = "TestWSService", serviceName = "TestWSService")
      public class TestWSImpl implements TestWS {
       public String test(TestEnv testEnv) {
       if (testEnv.getTestAAA() instanceof TestAAA) {
       return "WRONG, should not end up here";
       } else if (testEnv.getTestAAA() instanceof TestBBB) {
       return "CORRECT";
       return "ERROR..";
      public class TestEnv implements Serializable {
       private static final long serialVersionUID = 1L;
       TestAAA testAAA;
       public TestAAA getTestAAA() {
       return testAAA;
       public void setTestAAA(TestAAA testAAA) {
       this.testAAA = testAAA;
      public class TestAAA implements Serializable {
       private static final long serialVersionUID = 1L;
       int a = 1;
      public class TestBBB extends TestAAA implements Serializable {
       private static final long serialVersionUID = 1L;
       int b = 2;

      Then I've tried both with SoupUI and a generated ws-client - but I always get a testAAA instead of testBBB. example from ws-client:
      TestWSService testWS = ts.getTestWSServicePort();
      TestBBB testBBB = new TestBBB();
      TestEnv testEnv = new TestEnv();
      String s = testWS.test(testEnv);

      I also have logged the http soap request and it looks ok (with xsi:type for the inherited class), here is the parameter:
      <testAAA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:testBBB"/>

      This is from the generated wsdl: (which have a correct "extension base=..")
      <xs:complexType name="test">
      <xs:element minOccurs="0" name="arg0" type="tns:testEnv"/>
      <xs:complexType name="testEnv">
      <xs:element minOccurs="0" name="testAAA" type="tns:testAAA"/>
      <xs:complexType name="testAAA">
      <xs:complexType name="testBBB">
      <xs:extension base="tns:testAAA">

      Any help would be appreciated!