Axis can serialize (at least a few) Collections. I read somewhere it can
handle Set and a few others I can't remember. (If I could only remember
where I read it).
I too use hibernate and have several Set's in my beans, axis replaces
them underwater with an array.
The soap output will look like this: (roles is actually a Set)
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
xsi:type="ns1:User"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:ns1="http://www.topicus.nl/parnassys";>
  <roles href="#id3" /> 
</multiRef>
<multiRef id="id3" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
xsi:type="soapenc:Array" soapenc:arrayType="xsd:anyType[2]"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";>
  <item href="#id5" /> 
  <item href="#id6" /> 
</multiRef>

the wsdl contains this element:
<element name="roles" type="impl:Set" nillable="true"/>


-----Oorspronkelijk bericht-----
Van: Brent Johnson [mailto:[EMAIL PROTECTED] 
Verzonden: maandag 2 augustus 2004 21:35
Aan: [EMAIL PROTECTED]
Onderwerp: Re: Newbie: Sending/Receiving Beans with BeanSerializer

Ahh.. so just return the bean that I want.. and I'm guessing I should
use call.setReturnClass(MyBean.class) instead of setReturnType?

Also.. I'm changing my beans to not use collections and use arrays
instead.  Can I use arrays of beans in my bean though?  Example:

public class MyBean() {
    private Attribute[] attributes;

    public MyBean() {
    }

    public Attribute[] getAttributes() { return(this.attributes); }
    public void setAttributes(Attribute[] param) { this.attributes =
param; }
}

And the Attribute class is just a bean that has a String name, and
String value.

When I try this I get the following error:
"org.xml.sax.SAXException: SimpleDeserializer encountered a child
element, which is NOT expected, in something it was trying to
deserialize."

I'm using Hibernate (http://www.hibernate.org) to link two tables in a
one-to-many relationship, and it requires that this be either a
collection, or an array of my custom bean.  If I have to I can modify
my parent bean to contain a String[] array instead.. holding all the
primary keys in the child database.. but this will require a little
more "finesse" to get working correctly.

Thanks for the help,

- Brent

----- Original Message -----
From: Callahan, Paul <[EMAIL PROTECTED]>
Date: Mon, 2 Aug 2004 14:07:11 -0400 
Subject: RE: Newbie: Sending/Receiving Beans with BeanSerializer
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>

 

Just make the return type of your method the class of the bean you
want to return...  Axis will serialize it on return, unless you are
using collections or complex types.

-pc 

 

-----Original Message----- 
From: Brent Johnson [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 02, 2004 1:10 PM 
To: [EMAIL PROTECTED] 
Subject: Newbie: Sending/Receiving Beans with BeanSerializer 
 

I want to be able to pass a bean (lets say "Item") to my WebService 
and have a bean returned (in this case another "Item" with different 
values). 

I've read through the Axis documentation and it looks like its pretty 
trivial to pass a bean into the service as input using the 
BeanSerializer.  This is of course assuming you aren't using any 
Collections.  I'd *like* to use Collections (i.e. a Set) in my bean.. 
but from searching the mailing list archive there doesnt seem to be a 
simple way to do this.  I can use arrays instead of collections for 
now though. 

How does one go about passing a bean back to the client?  The example 
in the user documentation takes a bean and just returns a String to 
the caller.  How about returning a serialized bean? 

Thanks

Reply via email to