2 Replies Latest reply on Apr 8, 2008 2:50 PM by raags

    Use Map as return type/parameter in a web method..

    raags

      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?