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 Problem passing object parameter to Ws method (JAX-RS + JAXB) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Problem passing object parameter to Ws method (JAX-RS + JAXB)" Watch "Problem passing object parameter to Ws method (JAX-RS + JAXB)" New topic

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

diego santos

Joined: Nov 15, 2012
Posts: 1
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?

I agree. Here's the link:
subject: Problem passing object parameter to Ws method (JAX-RS + JAXB)
It's not a secret anymore!