1 Reply Latest reply on Dec 6, 2007 6:24 AM by Shoeb Khan

    ArrayList or Set as return type in a web method ?

    Anis Ben Mahmoud Newbie

      Hi,

      Is it possible to have a web method which returns a Set or an ArrayList ?

      For examle :

      @WebMethod
      public ArrayList<Equipe> getEquipeList() {
       EquipeBean equipeBean = getEquipeBean();
       ArrayList<Equipe> equipes = (ArrayList<Equipe>)equipeBean.getEquipeList();
       return equipes;
      }
      


      Regards.
      Anis

        • 1. Re: ArrayList or Set as return type in a web method ?
          Shoeb Khan Newbie

          You can return any object of any complex data structure, as long as you can write an xml schema for that.
          However, rather than returning the Set object, you could return an array, which could further be cast down to a set by the client application.
          The purpose of web services is to have a standard interface that both parties agree with (the provider of the service and the client). You should keep your interface simple so that you can write a simple schema for that. That will be easier for you to manage and simple for your client to understand.
          If you want to re-use the component in your application that you want to expose as web service, you can write an adapter class to your business method. And expose that adapter's interface to client. So in future if you change the original method's signature your clients will still get benefit.

          Hope that helps.