This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Web Services and the fly likes Is JAX-WS method ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Web Services
Bookmark "Is JAX-WS method ArrayList" Watch "Is JAX-WS method ArrayList" New topic

Is JAX-WS method ArrayList

Satya Narayan

Joined: Jun 18, 2008
Posts: 6
Hello to all.

I have made one web service using JAX-WS. In that i have made one method which return ArrayList.

code :
@WebMethod(operationName = "getStudentList")
public ArrayList getStudentList(@WebParam(name = "StudentId")
String StudentId)

ArrayList al = new ArrayList();

//TODO write your implementation code here

return al;

When i am trying to access this method from Client Application it will show error message such as.
Error Message : Unsupported Content-Type: text/html;charset=utf-8 Supported ones are: [text/xml]

Why this error occur and what is solution.

Thanks in advance.
Vijay Gadde
Ranch Hand

Joined: Sep 30, 2008
Posts: 54
You create a separate bean with name ResponseData and in that bean you create this Array list object and while returning set data into this ArrayList and return it. Thats what I am practicing my current Web Services code

Hope this helps, Thanks Vijay Gadde

Vijay Gadde
Coming together is a beginning. Keeping together is progress.. Working together is success........
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12999
Return ArrayList - My advice is DONT!

Use the very handy toArray method and define your method to return an array. Arrays of common types are supported by all languages - Net, Python, javascript, whatever, that may want to talk to your web service, but the ArrayList class is Java only.

There is really no reason for any client program to receive an ArrayList.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Is JAX-WS method ArrayList
It's not a secret anymore!