Learner
Learner

Reputation: 2339

Return complex collection to client in REST Jersey?

I need to return a collection to calling client from REST webservice,

I did a wrapper something like below,

**

**

    public Collection<FundBalanceSetProperties> getVal() {
        return ListN;
    }

    public void setVal(Collection<FundBalanceSetProperties> list) {
        // TODO Auto-generated method stub
        this.ListN = list;
}

I tried to get the value set as below,

**

**

@GET
@Produces({ MediaType.TEXT_XML })
public Todo getHTML() throws Exception {
    Todo todo = new Todo();
    Collection<FundBalanceSetProperties> list = myDal.getFundBalanceSet(null, null,
            null, null, null, null);
    todo.setVal(list);
    return todo;
}

But I am getting error

"Exception in thread "main"

com.sun.jersey.api.client.UniformInterfaceException:"

Can someone please help me with returning collection to calling client?

Upvotes: 1

Views: 2242

Answers (1)

Dan Hardiker
Dan Hardiker

Reputation: 3053

The two easy options you have are:

  1. Return an Array (FundBalanceSetProperties[]) instead of a Collection
  2. Use Jackson: How to reuse Jersey's JSON/JAXB for serialization?

Upvotes: 1

Related Questions