[jboss-user] [JBossWS] - Problem with inheritance - JbossWS

fghj5678 do-not-reply at jboss.com
Wed Feb 11 10:46:45 EST 2009


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:

  | @WebService
  | public interface TestWS {
  |     
  |     public String test(TestEnv testEnv);
  | }
  | 
  | 
  | @Stateless
  | @WebService(name = "TestWSService", serviceName = "TestWSService")
  | @Remote(TestWS.class)
  | 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;
  |     }    
  | }
  | 
  | @XmlSeeAlso({TestBBB.class})
  | 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();
  | testEnv.setTestAAA(testBBB);
  | 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:sequence>
  | <xs:element minOccurs="0" name="arg0" type="tns:testEnv"/>
  | </xs:sequence>
  | </xs:complexType>
  | <xs:complexType name="testEnv">
  | <xs:sequence>
  | <xs:element minOccurs="0" name="testAAA" type="tns:testAAA"/>
  | </xs:sequence>
  | </xs:complexType>
  | <xs:complexType name="testAAA">
  | <xs:sequence/>
  | </xs:complexType>
  | <xs:complexType name="testBBB">
  | <xs:complexContent>
  | <xs:extension base="tns:testAAA">
  | <xs:sequence/>
  | </xs:extension>
  | </xs:complexContent>
  | </xs:complexType>
  | 

Any help would be appreciated!

Mats.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4209119#4209119

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4209119



More information about the jboss-user mailing list