File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jax-ws : return list of JPA entities

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a simple jax-ws service for an iphone application. I am using EJB 3.0 entities and hibernate as JPA implementation.

I'll have a operation getUsers, that should return the list of users with all the attributes of users fetched from DB.

If I return something like this :




The problem is that I am unable to make my web service deployed If I use generics.

And if I remove generic code and rather use normal "List", the web service is deployed but if I call this service I get an exception.

My question is, if I am somehow able to resolve the problem, will the jax-ws runtime be able to send the SOAP message something like this :



I suspect this is not possible, I guess I will have to create xml manually ? But then what's use of using jax-ws ?

Can someone help me out on this? I need to send the data from the JPA entities in xml form.

Thanks


 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
First of all, do not use the List type as a return type form a web service method. Use arrays instead.
JAXB, who is responsible for marshalling and unmarshalling XML data does not know about Lists, since this is not a simple Java type.
Arrays, however, is no problem for JAXB.

Second, when querying for entities from a database or such, be sure not to use lazy loading and also detach the entities from the entity context before returning them.
This because if you, for instance, use lazy loading and return entities which data is not completely loaded, then there may be problems if the entity context is closed when the serialization of the entities to XML is done.
Best wishes!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic