Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Rest WebServices with Json only accepts Objects?

managed BEANSep 2 2015 — edited Sep 9 2015

Hi

Using JDEV 12.1.3.0.0 is it possible to send from webservice a List and receive it in the client side?

I wanted just this:

@Stateless

@Path("/costumer")

public class CostumerImpl {

  

    @EJB

    SessionEJBnameLocal myBean;

    @GET

    @Produces(value = { "application/json", "application/xml" })

    @Path("/list")

    public List<CostumerEO> lista(){

        return myBean.getCostumerEOFindAll();

    }

}

The only way i found was to create an Object with a List,as showned below, send that Object and this way worked:

@XmlRootElement

public class CustomerList {

 

  List<Customer> customerList = new ArrayList<Customer>();

  public void setCustomerList(List<Customer> customerList) {

  this.customerList = customerList;

  }

  @XmlElement(name = "allcustomers")

  public List<Customer> getCustomerList() {

  return customerList;

  }

}

But i would like not to create this object.

Is it possible?

JDev 12.1.3.0.0

Any help would be appreciated.

Regards

Carlos

This post has been answered by managed BEAN on Sep 9 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2015
Added on Sep 2 2015
11 comments
5,177 views