/* StringReturn.jws by Jeffrey K. Brown I was curious at this point to see what would happen if I started importing additional libraries and then writing my own methods not in the book. This worked well. I was able to connect to this web service with a quick and dirty C#.NET application. Basically, I would write a word or two in a text box, and when you clicked a button, the web service would be invoked with the parameter from the text box. This code doesn't do anything interesting or even exciting. Basically, I needed a web service that does something so that I could test it and play with it. */ import java.util.*; public class StringReturn { // This is basically an echo function. public String returnString (String whole) { return whole; } // If we pass a sentence, we tokenize and return the first word. public String returnFirst (String whole) { try { StringTokenizer st = new StringTokenizer(whole); return st.nextToken(); } catch (Exception e) { return "Exception"; } } // This returns an array of Strings public String[] returnArray (String whole) { int i=0; String[] array = new String[10]; for (i=0; i<10; ++i) { array[i] = whole + " " + i; } return array; } }