File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Web Services
Bookmark "Apache CXF - ignore setters when marshalling" Watch "Apache CXF - ignore setters when marshalling" New topic

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

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:
subject: Apache CXF - ignore setters when marshalling
It's not a secret anymore!