Hello to all.

I have a problem with Axis2 and XMLBeans and I think that this could be a bug.

I have a WSDL-file with the following schemas:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
     targetNamespace="http://haschemi.org/sale/common";>

     <xsd:complexType name="product-type" abstract="true">
       <xsd:attribute name="id" type="xsd:long" />
     </xsd:complexType>

     <xsd:complexType name="milk-type">
       <xsd:complexContent>
         <xsd:extension base="common:product-type">
           <xsd:attribute name="fillingQuantity" type="xsd:float" />
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

     <xsd:element name="addProductRequest">
       <xsd:complexType>
         <xsd:sequence>
<xsd:element name="product" type="common:product-type" minOccurs="0" maxOccurs="unbounded" />
         </xsd:sequence>
       </xsd:complexType>
     </xsd:element>

     <xsd:element name="addProductResponse">
       <xsd:complexType>
         <xsd:sequence>
<xsd:element name="productId" type="xsd:long" minOccurs="0" maxOccurs="unbounded" />
         </xsd:sequence>
       </xsd:complexType>
     </xsd:element>

   </xsd:schema>

I used WSDL2Java to generate the service and the xmlbean-resources. The xmlbean-resources are packed into a jar file and placed in the lib-directory of the .aar service.

care
+ org
 + haschemi
 + ...
+ lib
+ XBeans-packaged.jar
+ META-INF
 + services.xml

The calling part is:

...
final AddProductRequestDocument addProductRequestDocument = AddProductRequestDocument.Factory.newInstance(); final AddProductRequest addProductRequest = addProductRequestDocument.addNewAddProductRequest();
final ProductType productType = addProductRequest.addNewProduct();
final MilkType milkType = (MilkType) productType.changeType(MilkType.type);
milkType.setFillingQuantity(44.44f);
...

In the generated Skeleton I put the following lines:

public org.haschemi.sale.common.AddProductResponseDocument addProduct(
           org.haschemi.sale.common.AddProductRequestDocument param0) {
final AddProductRequest addProductRequest = param0.getAddProductRequest();

for (ProductType productType : addProductRequest.getProductArray()) { final MilkType milkType = (MilkType) productType.changeType(MilkType.type); }
   }

I get a exception of the changeType call:
java.lang.ClassCastException: org.haschemi.sale.common.impl.ProductTypeImpl

It seems that the changeType method returns the abstract basetype (product-type) instead of the derived one (milk-type).


BUT the strangest thing is that is works outside of axis2. I wrote a litte Main-Class and I call the Skeleton manually and everything goes ok.

So I think that this can be a Axis2 Bug. Something with the classloader?



I'm sorry for the long e-mail.

Thanks a lot,

Siamak Haschemi






Reply via email to