This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes Apache CXF - ignore setters when marshalling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Apache CXF - ignore setters when marshalling" Watch "Apache CXF - ignore setters when marshalling" New topic
Author

Apache CXF - ignore setters when marshalling

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Hey guys,

I am playing around with Webservices and Apache CXF.

The framework does pretty much everything by itself which is nice. I did not quite get behind the mechanics of the automatic marshalling process.

It appears, that by default the framework scans the data classes to be shipped over the network to find setter and getter methods and those are the ones it will include in the marshalling process. This is not really what I want though. I would rather like the properties itself to be read.

I have found this to be working:



Now, what I want is only to ship the personID property. This one does not have a setter, as it should be set upon creating the Person instance. the XmlElement annotation does just what I want. It reads the property w/o using getters or setters. Perfect.
What I don't want though is the framework to include the name property in the webservice, which it does since there are setters and getters available.

I suspect that there is a simple xml configuration that would do just what i want. Maybe somebody knows.

This is what my beans.xml looks like now:



JDBCSupport - An easy to use, light-weight JDBC framework -
Daniel Kulp
Greenhorn

Joined: Dec 18, 2009
Posts: 2

The easiest method is to stick an @XmlTransient annotation on the name field. This is a JAXB thing, not really a CXF thing.



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Apache CXF - ignore setters when marshalling