How did you get a stub with a return of java.util.Collection.  I don't see
how WSDL2Java could produce this kind of stub.



Rich Scheuerle
XML & Web Services Development
512-838-5115  (IBM TL 678-5115)


                                                                                       
                                                
                      "David L. Cole"                                                  
                                                
                      <DLCole@cmsenergy        To:       [EMAIL PROTECTED]       
                                                
                      .com>                    cc:                                     
                                                
                                               Subject:  Collection Ser/Des            
                                                
                      03/26/2002 06:53                                                 
                                                
                      PM                                                               
                                                
                      Please respond to                                                
                                                
                      axis-dev                                                         
                                                
                                                                                       
                                                
                                                                                       
                                                



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




Reply via email to