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 Patrick van Kann <pa...@fortune-cookie.com> on 2005/02/23 13:47:17 UTC
Problem with serialization of Beans containing Collections and ArrayLists
I have integrated Axis 1.2 RC2 binary with an existing web app. I have a simple web service defined in my server-config.wsdd as follows:
<service
name="TimesheetWebService"
provider="java:RPC">
<parameter name="allowedMethods" value="*"/>
<parameter name="className" value="com.fc.timesheet.webservices.TimesheetWebService"/>
<beanMapping languageSpecificType="java:com.fc.timesheet.data.TestData"
qname="ns1:Test" xmlns:ns1="urn:data.timesheet.fc.com"/>
</service>
It has a single method that returns a simple JavaBean of type TestData.
The TestData JavaBean has a member that is a Vector:
private Vector tests = new Vector();
public Vector getTests() {
return this.tests;
}
public void setTests( Vector tests ) {
this.tests = tests;
}
If I generate the client and test case using WSDL2Java (based on the WSDL that the Axis Servlet produces automatically) the test case runs just fine.
However, if I change my TestData class to have a Collection (backed by an ArrayList) instead i.e.:
private Collection tests = new ArrayList();
public Collection getTests() {
return this.tests;
}
public void setTests( Collection tests ) {
this.tests = tests;
}
I get an error when I try re-deploy to the server and re-generate and re-run the client/test case:
"org.xml.sax.SAXException: Found character data inside an array element while deserializing"
What do I need to do differently to handle Collections/ArrayLists?
Thanks in advance,
Patrick
Re: Problem with serialization of Beans containing Collections and ArrayLists
Posted by Anne Thomas Manes <at...@gmail.com>.
That's right. Stick with arrays. Just say "no" to colllections.
- Anne
On Wed, 23 Feb 2005 13:55:44 +0100, Mariano Eloy Fernández
<fe...@gva.es> wrote:
> Hello,
>
> Patrick, an advise from a fool.
> Use MyClass[] instead of Vector or Collections, mainly becouse that way
> you provide the wrapped type to Axis' De/Serializers.
>
> Cheers,
>
> Mariano Eloy Fernández..
>
> Patrick van Kann wrote:
>
> > I have integrated Axis 1.2 RC2 binary with an existing web app. I have
> > a simple web service defined in my server-config.wsdd as follows:
> >
> > <service
> > name="TimesheetWebService"
> > provider="java:RPC">
> > <parameter name="allowedMethods" value="*"/>
> > <parameter name="className"
> > value="com.fc.timesheet.webservices.TimesheetWebService"/>
> > <beanMapping
> > languageSpecificType="java:com.fc.timesheet.data.TestData"
> > qname="ns1:Test" xmlns:ns1="urn:data.timesheet.fc.com"/>
> > </service>
> >
> > It has a single method that returns a simple JavaBean of type TestData.
> >
> > The TestData JavaBean has a member that is a Vector:
> >
> > private Vector tests = new Vector();
> >
> > public Vector getTests() {
> > return this.tests;
> > }
> >
> > public void setTests( Vector tests ) {
> > this.tests = tests;
> > }
> >
> > If I generate the client and test case using WSDL2Java (based on the
> > WSDL that the Axis Servlet produces automatically) the test case runs
> > just fine.
> >
> > However, if I change my TestData class to have a Collection (backed by
> > an ArrayList) instead i.e.:
> >
> > private Collection tests = new ArrayList();
> >
> > public Collection getTests() {
> > return this.tests;
> > }
> >
> > public void setTests( Collection tests ) {
> > this.tests = tests;
> > }
> >
> > I get an error when I try re-deploy to the server and re-generate and
> > re-run the client/test case:
> >
> > "org.xml.sax.SAXException: Found character data inside an array
> > element while deserializing"
> >
> > What do I need to do differently to handle Collections/ArrayLists?
> >
> > Thanks in advance,
> >
> > Patrick
> >
>
>
Re: Problem with serialization of Beans containing Collections and
ArrayLists
Posted by Mariano Eloy Fernández <fe...@gva.es>.
Hello,
Patrick, an advise from a fool.
Use MyClass[] instead of Vector or Collections, mainly becouse that way
you provide the wrapped type to Axis' De/Serializers.
Cheers,
Mariano Eloy Fernández..
Patrick van Kann wrote:
> I have integrated Axis 1.2 RC2 binary with an existing web app. I have
> a simple web service defined in my server-config.wsdd as follows:
>
> <service
> name="TimesheetWebService"
> provider="java:RPC">
> <parameter name="allowedMethods" value="*"/>
> <parameter name="className"
> value="com.fc.timesheet.webservices.TimesheetWebService"/>
> <beanMapping
> languageSpecificType="java:com.fc.timesheet.data.TestData"
> qname="ns1:Test" xmlns:ns1="urn:data.timesheet.fc.com"/>
> </service>
>
> It has a single method that returns a simple JavaBean of type TestData.
>
> The TestData JavaBean has a member that is a Vector:
>
> private Vector tests = new Vector();
>
> public Vector getTests() {
> return this.tests;
> }
>
> public void setTests( Vector tests ) {
> this.tests = tests;
> }
>
> If I generate the client and test case using WSDL2Java (based on the
> WSDL that the Axis Servlet produces automatically) the test case runs
> just fine.
>
> However, if I change my TestData class to have a Collection (backed by
> an ArrayList) instead i.e.:
>
> private Collection tests = new ArrayList();
>
> public Collection getTests() {
> return this.tests;
> }
>
> public void setTests( Collection tests ) {
> this.tests = tests;
> }
>
> I get an error when I try re-deploy to the server and re-generate and
> re-run the client/test case:
>
> "org.xml.sax.SAXException: Found character data inside an array
> element while deserializing"
>
> What do I need to do differently to handle Collections/ArrayLists?
>
> Thanks in advance,
>
> Patrick
>