Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jaxb Binding problem with List returned in web service response  RSS feed

 
yakoub damak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am developing a jax-ws client, I am trying to handle an ArrayList returned as a response, but i had always empty list.

Returned list is NOT empty, I am sure that WebService provider is returning data in that list, I checked that using SoapUI.

there is generated client related files:









when i write


"array" is always empty

How can i resolve this problem ??

Please help !
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the item value coming as null, is causing the issue. make sure the item value is set by the setter "setItem()", in debug mode.
 
yakoub damak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Radhakrishna,

When i capture the returned xml message, the list is filled with 60 items ans is NOT null. But in java there is no items ! So I think that is a problem of java xml binding of the returned list .. what do you think ?
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. If you are sure that the items are coming, then it's an issue in the XML to Java binding. Which binding mechanism you have used? My suggestion is to try with the JAXB marshalling/unmarshalling to handle the payload.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try returning an array, not an ArrayList. SOAP standards know about arrays but not the Java specific ArrayList object.

Bill
 
yakoub damak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Radhakrishna,

I used wsimport to generate client source files automatically. The generated files include jaxb annotations like (@XmlType, @XmlElement, ..), so should i add some specific annotations to wrap the arrayList content ?
 
yakoub damak
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William,

The Provider is given and i can't change its behaviour.
 
Radhakrishna Sharma Gorenta
Ranch Hand
Posts: 63
Google App Engine Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't marshall/unmarshal ArrayList (as other languages don't know ArrayList) but you can marshall/unmarshal List.
The issue is in ArrayOfWSV30Agglst class at the line :

Remove the instantiation of Arraylist(); Just declare the field as :

and also in getItem() method change to :

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!