You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Br...@correspondence.school.nz on 2003/06/23 15:07:12 UTC

Deserializing arrays -- ClassCastException -- help

Hi,

I've got a problem with axis 1.1 and any help would be appreciated. I've
got a simple service that has two simple methods:

Student getStudent();
Student[] getByName();

The getStudent() method works fine using the BeanSerializerFactory, but
I've got problems with the getStudentByName() method. Whenever I invoke it
I get a ClassCastException. I've tried calling it with a Call object, and
I've tried both with and without explicitly mapping the array, all to no
avail.

Here's the relavant part of my wsdd file (hand retyped, so pls forgive any
typos)

<service name="students2" provider="java:RPC">
  <parameter name="className" value'+com.greenpulse.demo.model.Students"/>
  <parameter name="allowedMethods" value="*"/>
  <beanMapping xmlns:myNS="urn:beanService" qname="myNS:student"
    langugageSpecificType="java:com.greenpulse.demo.model.Student"/>

  <typeMapping xmlns:myNS="urnBeanServiceArray"
    qname="myNS:students"
    type="java:com.greenpulse.demo.model.student[]"
    serializer="org.apache.axis.encoding.ser.ArraySerializerFactor"
    deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding"
</service>

I've also tried a generated client (wsdl2java) with the same results.
Here's the client based on the wsdl2java code:

StudentsServiceLocator locator = new StudensServiceLocator();
try {
  clientStudents students = locator.getstudents2();
  BeanService.Student[] byName = students.getByName("a%");
  for(int i = 0; i < byName.length; i++) {
    BeanService.Student student = byName[i];
    System.out.println("name = " + student.getFamilyName());
  }
  catch(Exception e) {
    e.printStackTrace();
  }
}

(again, this was hand-typed, so try to ignore any typo type errors :0))

Right, so there's the problem. If anyone has any ideas I'd love to hear
them.

TIA

Bryan