01: package jms.client.stub;
02:
03: import org.apache.wsif.WSIFService;
04: import org.apache.wsif.WSIFServiceFactory;
05: import org.apache.wsif.WSIFException;
06: import java.rmi.RemoteException;
07: import jms.client.stub.org.apache.xml.CheckAvailabilityPortType;
08:
09: /**
10: * Class that runs the jms sample using a pregenerated stub interface.
11: * To use this class, provide a zip code on the command line. WSIF
12: * should then invoke the JMS service with this information, returning with a
13: * true or false to indicate whether DSL service is avaiulable or not in that
14: * zip code.
15: * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
16: */
17:
18: public class Run {
19:
20: public static void main(String[] args) {
21: try {
22:
23: if (args.length != 2) {
24: System.out
25: .println("Usage: java jms.client.stub.Run <wsdl location> <zip code>");
26: System.exit(1);
27: }
28:
29: // create a service factory
30: WSIFServiceFactory factory = WSIFServiceFactory
31: .newInstance();
32:
33: // parse WSDL
34: WSIFService service = factory
35: .getService(
36: args[0],
37: null,
38: null,
39: "http://xml.apache.org/axis/wsif/samples/jms/ServiceAvailability",
40: "CheckAvailabilityPortType");
41: // create the stub
42: CheckAvailabilityPortType stub = (CheckAvailabilityPortType) service
43: .getStub(CheckAvailabilityPortType.class);
44:
45: // do the invocation
46: // args[1] is the zip code
47: String serviceAvailable = stub.checkAvailability(args[1]);
48: System.out.println(serviceAvailable);
49:
50: } catch (WSIFException we) {
51: System.out
52: .println("Error while executing sample, received an exception from WSIF; details:");
53: we.printStackTrace();
54: } catch (RemoteException re) {
55: System.out
56: .println("Error while executing sample, received an exception due to remote invocation; details:");
57: re.printStackTrace();
58: }
59: }
60: }
|