Appendix C. Sample server-side Web Service 381
O means On time.
C means Cancelled.
D means Delayed.
Example: C-1 DelayedFlights.java: getDelayedFlights() method
package com.itso.flightInfo;
import java.lang.reflect.Array;
import java.util.Random;
public class DelayedFlights {
public String[] getDelayedFlights(String[] flightNoArray)
{
String[] statusArray = new String [flightNoArray.length];
String flightNo;
if (flightNoArray != null) {
String[] status = {"C","D","O","O","O"};
Random generator = new Random();
for (int i=0; i<flightNoArray.length; i++) {
flightNo = (String)Array.get(flightNoArray,i);
Array.set(statusArray,i,status[generator.nextInt(5)]);
}
}
return statusArray;
}
}
Create a Web service
In this section, you will create a Web service in the DelayedFlightsWS project
using the wizards provided by WebSphere Studio Site Developer. Once created,
you will test the Web service in a WebSphere Test Environment.
1. Select File →New →Other, as in Figure C-7 on page 382.