Get your CodeRanch badge!*
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
Author

Is JAX-WS method ArrayList

Satya Narayan
Greenhorn

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 : com.sun.xml.ws.server.UnsupportedMediaException: 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
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
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.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is JAX-WS method ArrayList
 
Similar Threads
Inheritance
Recursion-Prime factors
JAX-RPC vs JAX-WS some differences
JTable as User's input (?)
New to Web services- Problem