Reputation: 4084
I have two classes annotated as follows in Jersey v1.13:
@XmlRootElement(name="request_pojo")
public class RequestPojo {
public String name;
@XmlElementWrapper(name = "nested_pojos")
@XmlElement(name = "nested_pojo")
public List<NestedPojo> nestedPojo;
}
@XmlRootElement(name="nested_pojo")
public class NestedPojo {
public String name;
}
When I attempt to use Jersey client to serialize a RequestPojo
that has a collection of NestedPojo
s ... I don't see them being marshalled in the logs:
INFO: 1 * Client out-bound request
23:30:45 web.1 | 1 > POST https://localhost:443/test/
23:30:45 web.1 | 1 > Content-Type: application/xml
23:30:45 web.1 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<request_pojo>
<name>blah</name>
</request_pojo>
What do I have to fix in order to see something like the following being put onto the wire by the jersey client?
<request_pojo>
<name>blah</name>
<nested_pojos>
<nested_pojo>
<name>nested blah</name>
</nested_pojo>
</nested_pojos>
</request_pojo>
Upvotes: 2
Views: 926
Reputation: 29693
As for me your code works well.
Possible problems:
1) In your implementation of List
iterator isn't implemented.
2) nestedPojo
is empty or null
. Debug project to check it
Upvotes: 1