Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem passing object parameter to Ws method (JAX-RS + JAXB)  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.

I am using Jersey to develop a web service that will be used as a middleware between an application and a database.

I am having a lot of trouble with one of my first methods, I am trying to insert new data into the database, from the test application using a simple web form I´m collecting some data and in the end calling the post method and trying to pass all I get from the form to the web service. I can reach the method but I´m not getting exactly the data I had when I called the service from the client.

The test Application has 4 classes, and one of them is the root of the XML, I mean, it has an instance of the other 3 and all of the got the @XmlRootElement and @XmlElement annotations from JAXB.

Here is how I am calling the service:

The atdn object is the "root" class.

And here is the post method:

My problem is that when I call the getValue() on the atdn (line above) it returns an object with most of its parameter as null. Curiously, the attributes of one of the inner classes has its values but I cannot figure out why.

Before calling the service I used the Marshall method just to print the XML structure on console and it appears quite right, but for some reason it is not in the same way in the WS side.

What is the problem?

Althogh the classes have the JAXB annotations I am passing an instance of the root class to the method because the tutorial I was following uses this way, but it doesn´t have other objects inside just simple attributes, could it be the problem? And what if I need to call the service from a PHP page or a .Net client?

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!