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.
382 WCTME: Application Development and Case Study
Figure C-7 Starting creation of Portlet project
2. Select Web Services Web Service and click Next. See Figure C-8 on
page 383.
Appendix C. Sample server-side Web Service 383
Figure C-8 Selection of Web Service
3. Enter the following information in the Web Services window (Figure C-9 on
page 384):
a. Web Service type: Java bean Web Service.
b. Check the box Start Web service in Web project.
c. Check the box Overwrite files without warning.
d. Check the box Create folders when necessary.
e. Optionally, you can select to generate a client proxy and configure its
options.
Click Next.
384 WCTME: Application Development and Case Study
Figure C-9 Web Service wizard
4. Click Edit in Server-Side Deployment Selection section (Figure C-10 on
page 385) and select the following:
–Server: Server Types WebSphere version 5.1 WebSphere v5.1
Test Environment
Web service runtime: IBM WebSphere V5.
Click Ok.
Appendix C. Sample server-side Web Service 385
Figure C-10 Service Deployment configuration
5. Click Next. See Figure C-11 on page 386.

Get IBM Workplace Client Technology Micro Edition Version 5.7.1: Application Development and Case Study now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.