Returning java.util.List in Axis


XML & Web services: Returning java.util.List in Axis

  1. Returning java.util.List in Axis (3 messages)


    When I generate the classes using a WSDL I get a return type of Object[] instead of the java.util.List object. From what I understand List is serializable.

    Any reason why it is changing the return type to Object[]?



    Threaded Messages (3)

  2. Returning java.util.List in Axis[ Go to top ]

    Here's a little more info on this subject:

    Java interface used to generate WSDL.
    import java.util.List;

    public interface iDAO {
            public List executeQuery(String s);
            public int executeUpdate(String s);

    WSDL file generate by running Java2WSDL using iDAO.class (above)
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://Interface.daopackage" xmlns:impl="http://Interface.daopackage" xmlns:intf="http://Interface.daopackage" xmlns:apachesoap="" xmlns:wsdlsoap="" xmlns:soapenc="" xmlns:xsd="" xmlns:wsdl="" xmlns="">
       <wsdl:message name="executeUpdateResponse">
          <wsdl:part name="executeUpdateReturn" type="xsd:int"/>
       <wsdl:message name="executeQueryResponse">
          <wsdl:part name="executeQueryReturn" type="soapenc:Array"/>
       <wsdl:message name="executeQueryRequest">
          <wsdl:part name="in0" type="xsd:string"/>
       <wsdl:message name="executeUpdateRequest">
          <wsdl:part name="in0" type="xsd:string"/>
       <wsdl:portType name="iDAO">
          <wsdl:operation name="executeQuery" parameterOrder="in0">
             <wsdl:input name="executeQueryRequest" message="impl:executeQueryRequest"/>
             <wsdl:output name="executeQueryResponse" message="impl:executeQueryResponse"/>
          <wsdl:operation name="executeUpdate" parameterOrder="in0">
             <wsdl:input name="executeUpdateRequest" message="impl:executeUpdateRequest"/>
             <wsdl:output name="executeUpdateResponse" message="impl:executeUpdateResponse"/>
       <wsdl:binding name="DAOServiceSoapBinding" type="impl:iDAO">
          <wsdlsoap:binding style="rpc" transport=""/>
          <wsdl:operation name="executeQuery">
             <wsdlsoap:operation soapAction=""/>
             <wsdl:input name="executeQueryRequest">
                <wsdlsoap:body use="encoded" encodingStyle="" namespace="http://Interface.daopackage"/>
             <wsdl:output name="executeQueryResponse">
                <wsdlsoap:body use="encoded" encodingStyle="" namespace="http://Interface.daopackage"/>
          <wsdl:operation name="executeUpdate">
             <wsdlsoap:operation soapAction=""/>
             <wsdl:input name="executeUpdateRequest">
                <wsdlsoap:body use="encoded" encodingStyle="" namespace="http://Interface.daopackage"/>
             <wsdl:output name="executeUpdateResponse">
                <wsdlsoap:body use="encoded" encodingStyle="" namespace="http://Interface.daopackage"/>
       <wsdl:service name="iDAOService">
          <wsdl:port name="DAOService" binding="impl:DAOServiceSoapBinding">
             <wsdlsoap:address location="http://thehost:8082/axis/services/DAOService"/>
    </wsdl:definitions> generated by running WSDL2Java using above WSDL.
     * This file was auto-generated from WSDL
     * by the Apache Axis WSDL2Java emitter.


    public interface IDAO extends java.rmi.Remote {
        public java.lang.Object[] executeQuery(java.lang.String in0) throws java.rmi.RemoteException;
        public int executeUpdate(java.lang.String in0) throws java.rmi.RemoteException;

    You will notice that the return type of executeQuery method is java.lang.Object[] rather than what was defined in interface whic is java.util.List.
  3. Returning java.util.List in Axis[ Go to top ]

        Axis generates client-side classes from the service's WSDL. In the WSDL you have NO WAY of knowing how is a collection (list, set or whatever) implemented in the server-side. So, Axis makes a choice and returns Object[].
        What if you're trying to use a third-party WebService? You don't know if it is implemented in Java (where you have java.util.List) or COBOL (where you have something else I don't know).
        I believe there's some weird way to plug your own code generator into WSDL2Java, if you MUST use java.util.List.

  4. Returning java.util.List in Axis[ Go to top ]

    Check this link:

    I think ur problem is similiar to the one expalined in the article....