• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get <param-name> instead of <item> in response when I am returning 2D array from WebService?

 
Wap Rau
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very new to Web Services. I am creating Apache CXF (apache-cxf-2.5.0) SOAP based Web Services. It creates WSDL from Java class (Java first approach).

When Web Service is called I am returning 2D array as a response. This is my Java class:


This is the response to the request I get when Web Service is called:


The Response that I get from the webservice has a tag <item> under <return> tag. However, I want <parameter-name> instead of <item> like this:


How to do it? Thanks.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
You should really try to avoid that kind of multidimensional arrays. It makes your code much more difficult to understand and maintain.
Instead, implement a Java-bean class that represents one row of data from, in this case, the database.
Then, for each row in the database query result, create an instance and populate its data.
Finally, insert each instance of the Java-bean in an array and return that array.
Best wishes!
 
Wap Rau
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Krizsan wrote:Hi!
You should really try to avoid that kind of multidimensional arrays. It makes your code much more difficult to understand and maintain.
Instead, implement a Java-bean class that represents one row of data from, in this case, the database.
Then, for each row in the database query result, create an instance and populate its data.
Finally, insert each instance of the Java-bean in an array and return that array.
Best wishes!
Thanks Ivan Krizsan, for your reply. I will try your solution.
 
Wap Rau
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan Krizsan wrote:Hi!
You should really try to avoid that kind of multidimensional arrays. It makes your code much more difficult to understand and maintain.
Instead, implement a Java-bean class that represents one row of data from, in this case, the database.
Then, for each row in the database query result, create an instance and populate its data.
Finally, insert each instance of the Java-bean in an array and return that array.
Best wishes!


Thanks Ivan Krizsan, It worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic