It's not a secret anymore!
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 13027
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 agree. Here's the link:
subject: Is JAX-WS method ArrayList
It's not a secret anymore!