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 Maurice Marrink <ma...@topicus.nl> on 2004/08/02 16:43:05 UTC

serialize only certain fields of bean

Hi,

I have a number of beans I want to serialize to a soap message. I use the
standard beanserializer that comes with axis 1.1 and that works great, but
now I have several fields in different beans that I don't want to serialize.
Example : Class A {
	private String a;
	private String b;
	private String c;
	private String d;
	//getters and setters
}
In the output soap message I only want so see the values for a and c. I came
across this thread on this mailinglist that suggested to use
<myClass>BeanInfo classes, and that worked great. Untill I found out those
classes interfered with the rest of the application. So I had to get ridd of
them. I also tried to use the <myClass>_Helper classes to specify a custom
TypeDesc, trying to fake those fields I did not need as attributes. Which
also doesn't work because those fields still get serialized only as
attribute instead of elements. minOccurs=0 in the TypeDesc also won't work
because then the fields would have to be null, which they are not.

Is there another way to tell axis which fields to serialize or is my only
hope to override beanserializer and do the serializing myself. The solution
is preferably something axis specific because the rest of my application is
using all the fields.

Here is the relevant part of my wsdd
<service name="UserService" provider="java:RPC" style="rpc" use="encoded" >
	<parameter name="className"
value="nl.topicus.bao.web.webservices.UserService"/>
	<parameter name="allowedMethods" value="*"/>
	<parameter name="scope" value="application"/>
	<namespace>http://www.topicus.nl/parnassys</namespace>
</service>

Thx,

Maurice Marrink


Re: serialize only certain fields of bean

Posted by Yves <li...@langisch.ch>.
it's written without c -> transient

Arnaud Vezain wrote:

>What about transcient property.
>In a classic serializable object, writing "transcient" before any field
>name allows to hide it to the serialization process.
>
>
>-----Original Message-----
>From: "Maurice Marrink" <ma...@topicus.nl>
>To: <ax...@ws.apache.org>
>Date: Mon, 2 Aug 2004 16:43:05 +0200
>Subject: serialize only certain fields of bean
>
>  
>
>>Hi,
>>
>>I have a number of beans I want to serialize to a soap message. I use
>>the
>>standard beanserializer that comes with axis 1.1 and that works great,
>>but
>>now I have several fields in different beans that I don't want to
>>serialize.
>>Example : Class A {
>>	private String a;
>>	private String b;
>>	private String c;
>>	private String d;
>>	//getters and setters
>>}
>>In the output soap message I only want so see the values for a and c. I
>>came
>>across this thread on this mailinglist that suggested to use
>><myClass>BeanInfo classes, and that worked great. Untill I found out
>>those
>>classes interfered with the rest of the application. So I had to get
>>ridd of
>>them. I also tried to use the <myClass>_Helper classes to specify a
>>custom
>>TypeDesc, trying to fake those fields I did not need as attributes.
>>Which
>>also doesn't work because those fields still get serialized only as
>>attribute instead of elements. minOccurs=0 in the TypeDesc also won't
>>work
>>because then the fields would have to be null, which they are not.
>>
>>Is there another way to tell axis which fields to serialize or is my
>>only
>>hope to override beanserializer and do the serializing myself. The
>>solution
>>is preferably something axis specific because the rest of my
>>application is
>>using all the fields.
>>
>>Here is the relevant part of my wsdd
>><service name="UserService" provider="java:RPC" style="rpc"
>>use="encoded" >
>>	<parameter name="className"
>>value="nl.topicus.bao.web.webservices.UserService"/>
>>	<parameter name="allowedMethods" value="*"/>
>>	<parameter name="scope" value="application"/>
>>	<namespace>http://www.topicus.nl/parnassys</namespace>
>></service>
>>
>>Thx,
>>
>>Maurice Marrink
>>
>>
>>
>>
>>    
>>
>
>
>
>
>
>  
>


Re: serialize only certain fields of bean

Posted by Arnaud Vezain <a....@nancy.fnclcc.fr>.
What about transcient property.
In a classic serializable object, writing "transcient" before any field
name allows to hide it to the serialization process.


-----Original Message-----
From: "Maurice Marrink" <ma...@topicus.nl>
To: <ax...@ws.apache.org>
Date: Mon, 2 Aug 2004 16:43:05 +0200
Subject: serialize only certain fields of bean

> Hi,
> 
> I have a number of beans I want to serialize to a soap message. I use
> the
> standard beanserializer that comes with axis 1.1 and that works great,
> but
> now I have several fields in different beans that I don't want to
> serialize.
> Example : Class A {
> 	private String a;
> 	private String b;
> 	private String c;
> 	private String d;
> 	//getters and setters
> }
> In the output soap message I only want so see the values for a and c. I
> came
> across this thread on this mailinglist that suggested to use
> <myClass>BeanInfo classes, and that worked great. Untill I found out
> those
> classes interfered with the rest of the application. So I had to get
> ridd of
> them. I also tried to use the <myClass>_Helper classes to specify a
> custom
> TypeDesc, trying to fake those fields I did not need as attributes.
> Which
> also doesn't work because those fields still get serialized only as
> attribute instead of elements. minOccurs=0 in the TypeDesc also won't
> work
> because then the fields would have to be null, which they are not.
> 
> Is there another way to tell axis which fields to serialize or is my
> only
> hope to override beanserializer and do the serializing myself. The
> solution
> is preferably something axis specific because the rest of my
> application is
> using all the fields.
> 
> Here is the relevant part of my wsdd
> <service name="UserService" provider="java:RPC" style="rpc"
> use="encoded" >
> 	<parameter name="className"
> value="nl.topicus.bao.web.webservices.UserService"/>
> 	<parameter name="allowedMethods" value="*"/>
> 	<parameter name="scope" value="application"/>
> 	<namespace>http://www.topicus.nl/parnassys</namespace>
> </service>
> 
> Thx,
> 
> Maurice Marrink
> 
> 
> 
>