title: Returning an ArrayList from a WebService in Java
body: <p>I am having a problem returning an ArrayList from my web service (Java).</p>
  
  <p>I have written a test web service and client which consumes it.  All appears to work fine - that is the client is calling the server and the server receives the operation request.</p>
  
  <p>However, I have written a simple method that I want it to return an ArrayList.</p>
  
  <p>I have my interface definition as follows:</p>
  
  <pre><code>@WebService
  @SOAPBinding(style = Style.RPC)
  public interface ISQLServerConnectionWS {
  
      @WebMethod
      ArrayList getSimpleArrayList();
  }
  </code></pre>
  
  <p>I have my server side implementation to return the ArrayList:</p>
  
  <pre><code>@WebService(endpointInterface="WebServices.ISQLServerConnectionWS")
  public class SQLConnectionWSServer
      implements ISQLServerConnectionWS {
  
      @Override
      public ArrayList getSimpleArrayList() {
          ArrayList al = new ArrayList();
          al.add( "This" );
          al.add( "is" );
          al.add( "a" );
          al.add( "test" );
          return al;
      }
  }
  </code></pre>
  
  <p>And finally my client call to it:</p>
  
  <pre><code>ArrayList results = server.getSimpleArrayList();
  </code></pre>
  
  <p>The server populates the array list fine.  However, back at the client side, the ArrayList is empty.  It has a size of 0.</p>
  
  <p>If I examine the WSDL at my URL (<a href="http://127.0.0.1:9876/myservice-sql?wsdl" rel="nofollow">http://127.0.0.1:9876/myservice-sql?wsdl</a>) for the executeSelectSQL, it looks like:</p>
  
  <pre><code>&lt;message name="executeSelectSQLResponse"&gt;
      &lt;part name="return" type="tns:arrayList"/&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p>Am I missing something obvious?</p>
  
  <p>Edit:</p>
  
  <p>However, if I have a web method defines in the interface as:</p>
  
  <pre><code>@WebMethod
  String getAString();
  </code></pre>
  
  <p>and the server implementation:</p>
  
  <pre><code>@Override
  public String getAString() {
      return "hello there";
  }
  </code></pre>
  
  <p>then this works fine - <code>"hello there"</code> is received on the client.</p>