You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Rosén Håkan <ha...@kvadrat.se> on 2004/03/01 08:50:57 UTC
SV: How to return array of beans
Hi !
Sorry for my late answer,
a Collection would do just fine !
I'd appreciate to see your sample code !
Thanks in advance
/Håkan
-----Ursprungligt meddelande-----
Från: Tony Blair [mailto:hrh747@yahoo.com]
Skickat: den 27 februari 2004 19:35
Till: axis-user@ws.apache.org
Ämne: Re: How to return array of beans
Hi there,
I have a similar sample code. It takes a bean as an input but it returns a
Collection of beans as oppose to an Array of beans. Is it possible for you
to use Collection?
Cheers,
Tony.
Rosén_Håkan <ha...@kvadrat.se> wrote:
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:
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:album="http://www.soapinterop.org/Album">
http://www.soapinterop.org/Album
languageSpecificType="java:company.beans.Album"/>
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
_____
Do you Yahoo!?
Get better spam protection with Yahoo!
<http://us.rd.yahoo.com/mailtag_us/*http://antispam.yahoo.com/tools> Mail