• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

jax-ws : return list of JPA entities

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic