In XFire, you could always use the annotation @IgnoreProperty (see org.codehaus.xfire.aegis.type.java5). However, for whatever reason, it appears Apache CXF doesn't want to support it any longer and is currently marked as deprecated, but still in there for backward compatibility. Hopefully, they either decide to support it or give us an alternative to eliminating an entity property from the WSDL generation. See http://xfire.codehaus.org/Aegis+Java+5+Annotations and http://cxf.apache.org/javadoc/latest/org/codehaus/xfire/aegis/type/java5/IgnoreProperty.html Ron Grimes
________________________________ From: [email protected] on behalf of David Castro Sent: Thu 3/5/2009 4:00 PM To: [email protected] Subject: Re: Specifying fields to include/exclude from return XML Hrmm, how about dynamically? Really what I am going for is something like: http://myapiserver.com/api/contacts?fields=id So this: <contact> <id>0</id> <firstName>A</firstName> <lastName>B</lastName> </contact> turns into this: <contact> <id>0</id> </contact> Although, in my particular case, I wouldn't just mind stripping out all XML elements with empty content. I've already got a filter/interceptor to empty fields I want to remove from the result XML...but those tags still get included, which I want to avoid. Want to compress the XML to only fields that have data. Would still be great if there were simply a way of telling CXF on the fly that only certain fields should make their way into the XML. If you are aware of a better way...I'm all ears =) Thanks, David On Thu, Mar 5, 2009 at 2:50 PM, Ian Roberts <[email protected]>wrote: > David Castro wrote: > > Is anyone is aware of how I can dynamically tell CXF (and thus JAXB) that > > there are some fields I want excluded from the resultant XML being > returned? > > > > I don't want to reinvent the wheel if I don't have to, but I can't find > > information on how to do what I want using the CXF framework rather than > > having to parse the XML outbound and remove what needs removing. Ideas? > > @XmlTransient tells JAXB to exclude particular fields. You might need > to annotate either the field directly or its get/set methods, depending > on the @XmlAccessorType of the containing class. > > Ian > > -- > Ian Roberts | Department of Computer Science > [email protected] | University of Sheffield, UK >
