Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is JAX-WS method ArrayList

 
Satya Narayan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic