axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Patton <m_patt...@yahoo.com>
Subject [Axis2] returning Array versus List , and more
Date Fri, 06 Jul 2007 13:55:05 GMT
I have a simple WS that has an Employee class (Pojo with getters and setters only), and a service
class EmployeeService that has only one method that takes 3 String arguments and  returns
a List of Employee objects. The actual list implementation returned is ArrayList.
   
  First is such a return type portable? Is it better to return Arrays instead?
   
  Second, how can I, from a client application,  retrieve the Employee objects from the list?
I wrote the client code below but it is throwing the following exception. Could anyone point
me to a tutorial or give a sample code to retrieve collection data from an Axis2 web service?
  Regards,
   
   
   
  Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unexpected
subelement return
    at com.myCompany.service.EmployeeServiceSOAP11PortStub.fromOM(EmployeeServiceSOAP11PortStub.java:1342)
    at com.myCompany.service.EmployeeServiceSOAP11PortStub.getEmployees(EmployeeServiceSOAP11PortStub.java:159)
    at com.myCompany.client.Main.main(Main.java:34)
Caused by: java.lang.RuntimeException: Unexpected subelement return
    at com.myCompany.service.EmployeeServiceSOAP11PortStub$GetEmployeesResponse$Factory.parse(EmployeeServiceSOAP11PortStub.java:667)
    at com.myCompany.service.EmployeeServiceSOAP11PortStub.fromOM(EmployeeServiceSOAP11PortStub.java:1336)
    ... 2 more
    
    
    
    
The line 34 is:  EmployeeServiceSOAP11PortStub.GetEmployeesResponse getEmployeesResponse =
stub.getEmployees(getEmployees);
    ------------------------------------------------------------
    
package com.myCompany.client;

import java.rmi.RemoteException;
import org.apache.axis2.AxisFault;
import javax.xml.stream.XMLStreamException;
import org.apache.axiom.om.OMElement;
import com.myCompany.service.EmployeeServiceSOAP11PortStub;
import com.myCompany.service.EmployeeService;
import com.myCompany.domain.Employee;
import java.util.List;

public class Main {
  public static void main(String[] args) {
     EmployeeServiceSOAP11PortStub stub;
     try{
           stub = new EmployeeServiceSOAP11PortStub("http://localhost:8080/axis2/services/EmployeeService");
           EmployeeServiceSOAP11PortStub.GetEmployees getEmployees = new EmployeeServiceSOAP11PortStub.GetEmployees();
           getEmployees.setViewDescription("GC_ALL");
           getEmployees.setUsername("Mike.Patton");
           getEmployees.setPassword("myPassword");
        ........
           EmployeeServiceSOAP11PortStub.GetEmployeesResponse getEmployeesResponse = stub.getEmployees(getEmployees);
           OMElement omelement = getEmployeesResponse.get_return();
           System.out.println(omelement.toStringWithConsume());
      }catch(AxisFault e){
           e.printStackTrace();
      }catch(RemoteException e){
           e.printStackTrace();
      }catch(XMLStreamException e){
           e.printStackTrace();
      }
   }
}



 
---------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
Mime
View raw message