I take back my first statement.  You don't have an array encapsulated inside another 
type.  Sorry I got confused.

Unfortunately, I don't have an answer for you at this time.

Bill



 -----Original Message-----
From:   Heitzeg, Bill  
Sent:   Friday, February 27, 2004 2:20 PM
To:     [EMAIL PROTECTED]
Subject:        RE: How to return array of beans

I described this earlier in a post.  Basically it comes down to modifying your beans.  
Wherever you have an array, you have to provide methods to set the array, get the 
array, set an individual item in the array, and get an individual item in an array.

For a String[] you would have the following getter setter methods in your array:
        
        
        public java.lang.String[] getItem()
        {
                return item;
        }

        public void setItem(java.lang.String[] item)
        {
                this.item = item;
        }
        public java.lang.String getItem(int i)
        {
                return this.item[i];
        }
        public void setItem(int i, java.lang.String value)
        {
                this.item[i] = value;
        }

Let me know if this works for you or if you need additional information.


 -----Original Message-----
From:   Rosén Håkan [mailto:[EMAIL PROTECTED] 
Sent:   Friday, February 27, 2004 8:48 AM
To:     '[EMAIL PROTECTED]'
Subject:        How to return array of beans

Hi 
I try to deploy a service but i'm stuck halfways.
I have written a small service that takes a javabean (Album) as input and
returns an array of the same bean (Album[]) as output, 
I can call my service with a bean-parameter but when I return the array I
get a ClassCastException.
I think my problem is that i have to descibe the returning Array as well,
but i don't know how

the method in my service looks like :
    public Album[] getAlbums( Album anAlbum ) {


wsdd-file:
<deployment xmlns="http://xml.apache.org/axis/wsdd/";
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";
xmlns:album="http://www.soapinterop.org/Album";>
    <service name="Album" provider="java:RPC">
        <namespace>http://www.soapinterop.org/Album</namespace>
        <parameter name="className" value="com.nice.service.AlbumService"/>
        <parameter name="allowedMethods" value="getAlbums"/>
    </service>
    <beanMapping qname="album:Album"
languageSpecificType="java:company.beans.Album"/>
</deployment>

Extact from client-code:
Album[] result = new Album[0];
call.removeAllParameters();
call.setTargetEndpointAddress(endpointURL);

call.setUseSOAPAction(true);
call.setSOAPActionURI("http://www.soapinterop.org/Album";);
QName albumqn = new QName("http://www.soapinterop.org/Album";,
                               "Album");
Class cls = Album.class;
call.registerTypeMapping(cls, 
                         albumqn, 
                         BeanSerializerFactory.class,
                         BeanDeserializerFactory.class);
call.setOperationName( new QName("http://www.soapinterop.org/Album";,
"getAlbums" ));

QName albumRetqn = new
QName("http://www.soapinterop.org/Album","ArrayOfAlbum";);
call.registerTypeMapping(result.getClass(), albumRetqn,
ArraySerializerFactory.class, ArrayDeserializerFactory.class);
call.addParameter( "anAlbum", albumqn, ParameterMode.IN );
call.setReturnType(albumRetqn);
//invoking the call return in a ClassCastException
Object ret = call.invoke(new Object[] { anAlbum });

regards 
/Håkan




Reply via email to