[jboss-user] [JBossWS] - Use Map as return type/parameter in a web method..

raags do-not-reply at jboss.com
Mon Apr 7 17:21:27 EDT 2008


I tried to use Map as a return type in one of my web service methods but I got a JAXB error stating that it does not support Map because it's an interface.

So I added an adapter for the Map but it gets ignored. Is it because JBossWS 1.2.1 GA does not support JAXB annotations on its classes? Do you know? 


  | @Stateless
  | @WebService()
  | @Local(IHelloWorldService.class)
  | @Remote(IHelloWorldService.class)
  | @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED) 
  | @XmlRootElement(name="HelloWorldBean")
  | public class HelloWorldBean 
  | {
  | 
  | @XmlJavaTypeAdapter(MapAdapter.class)
  | 	@XmlJavaTypeAdapter(CourseListAdapter.class)
  | 	public void getMap(Map<String,Course> map) 
  | 	{
  | 		
  | 		
  | 	}
  | }
  | class CourseListAdapter extends XmlAdapter<Course[],Map<String,Course>> {
  | 	  public Map<String,Course> unmarshal( Course[] value ) {
  | 	    Map<String,Course> r = new HashMap<String,Course>();
  | 	    for( Course c : value )
  | 	      r.put(c.id,c);
  | 	    return r;
  | 	  }
  | 	  
  | 	  public Course[] marshal( Map<String,Course> value ) {
  | 	    return value.values().toArray(new Course[value.size()]);
  | 	  }
  | 	
  | 	}
  | 
  | 

Am I doing something wrong here?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142196#4142196

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142196



More information about the jboss-user mailing list