So far we've been passing arrays as parameters. Now let's use an array as the return value of a service method. We'll add a method to our service called getMostActive( ), which returns a String[] that contains the symbols for the most actively traded stocks of the day. Here's the new version of the BasicTradingService class:

Go ahead and redeploy the service now. Calling this service method from an Apache SOAP client is simple. There are no parameters to the service method, so we just have to set up the call and invoke it:

We cast the return value of ret.getValue to a String[], since that's the return type we're expecting. In past examples we were able to leave the value as an Object instance because we relied on the object's toString( ) method to display the value. In this case we need to iterate over the array, so it's necessary to cast the value to the appropriate array type. After that, we just find the array length and then loop over the array values, printing each one as we get to it. If you run this example you should see the following output:

ABC
DEF
GHI
JKL

The SOAP envelope returned by this method invocation is pretty straightforward: