This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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 Murach's Java Servlets and JSP this week in the Servlets 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.



 
wood burning stoves
 
subject: Apache CXF - ignore setters when marshalling
 
Similar Threads
Error with web.xml
contract first web service
Mule standalone: Failed to read schema document "AMQP issue"
Mule standalone: Failed to read schema document "AMQP issue"
CXF-RS throwing No operation matching request path /create is found