1

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

I did a wrapper something like below,

**

  • bean Wrapper

**

    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,

**

  • REST Service

**

@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?

Bhesh Gurung
  • 49,592
  • 20
  • 90
  • 140
Learner
  • 2,203
  • 6
  • 42
  • 79

1 Answers1

1

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?
Community
  • 1
  • 1
Dan Hardiker
  • 2,973
  • 15
  • 18