• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Apache CXF - ignore setters when marshalling

Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic