This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes How to get <param-name> instead of <item> in response when I am returning 2D array from WebService? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How to get <param-name> instead of <item> in response when I am returning 2D array from WebService?" Watch "How to get <param-name> instead of <item> in response when I am returning 2D array from WebService?" New topic
Author

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

Wap Rau
Greenhorn

Joined: Dec 01, 2011
Posts: 11
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

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!


My free books and tutorials: http://www.slideshare.net/krizsan
Wap Rau
Greenhorn

Joined: Dec 01, 2011
Posts: 11
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

Joined: Dec 01, 2011
Posts: 11
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to get <param-name> instead of <item> in response when I am returning 2D array from WebService?
 
Similar Threads
need to add namespace ns2: in the all webservices response tags.
Using EL to retrieve bean values
Response <item xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
how to select a block using awt inside an swt component
Traversing SOAP response using AXIOM/ADB binding