axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David L. Cole" <DLC...@cmsenergy.com>
Subject Collection Ser/Des
Date Wed, 27 Mar 2002 00:53:25 GMT
I have a method which returns a Collection. Below is the generated client
stub which accurately shows it will return a Collection.
However, the actual object typ of resp is Object[]. This causes a
ClassCastException.
    public java.util.Collection retrieveContractListForAsset() throws
java.rmi.RemoteException{
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        com.rbs.base.client.remote.RBSCall call = getCall();
        call.setReturnType(new javax.xml.rpc.namespace.QName
("http://util.java", "Collection"));
        call.setUseSOAPAction(true);
        call.setSOAPActionURI("");
        call.setOperationStyle("rpc");
        call.setOperationName(new javax.xml.rpc.namespace.QName
("http://business.agreement.rbs.com", "retrieveContractListForAsset"));

        Object resp = call.invoke(new Object[] {});

        if (resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)resp;
        }
        else {
             return (java.util.Collection) resp;
        }
    }

Currently to fix the problem, I modify the return line to the following:

             return (java.util.Collection)java.util.Arrays.asList((Object
[])resp);

The only side effect from this is that the client which called the method
should new a collection and pass in the return value from the stub
into the constructor which will copy the collection contents to the new
collection object.

i.e Collection col = new Vector( returnFromStubMethod);
or Collection col = new ArrayList( returnFromStubMethod);

Is there any plan to fix the stub generation or alternate suggestions?
Thanks,

David Cole


Mime
View raw message