users@jersey.java.net

[Jersey] Re: Client response unmarshalling question

From: Noah White <emailnbw_at_gmail.com>
Date: Tue, 1 May 2012 23:39:36 -0400

Arul,

Thanks for the pointers/code! I took your advice about IDEA auto-generatation and took my XML response dropped it in a file and had IDEA generate an XSD then I had it generate the JAXB classes from that. Interesting they generated slightly different results then what you have here but they worked fine as well.

I'm surprised the solution was as involved as it was, using @XMLRegistry/ObjectFactory etc. I would have thought two simple POJOs with basic JAXB annotations would have done the trick. For example I have another case where the response I parse looks like this:

<string xmlns="http://schemas.micrsoft.com/2003/10/Serialization/"">blah blah blah</string>

For that I was able to simply use:

@XmlRootElement(name = "string", namespace="http://schemas.micrsoft.com/2003/10/Serialization/")
public class StringResponseData {
        
        private String _string;

        @XmlValue
        public String getString() {
                return _string;
        }

        pubic void setString(String aString) {
                _string = aString;
        }

        public StringResponseData() {}

}

Which is why I thought I could simply nest this in a wrapper class for ArrayOfstring to take care of the other case.

Anyhow, much appreciated! Thanks,

-Noah