This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Jaxb Binding problem with List returned in web service response

 
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 !
 
Ranch Hand
Posts: 63
Spring Java Google App Engine
  • 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
Spring Java Google App Engine
  • 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.
 
Author and all-around good cowpoke
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
Spring Java Google App Engine
  • 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 :

 
Won't you be my neighbor? - Fred Rogers. tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic