KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jms > client > stub > Run


1 package jms.client.stub;
2
3 import org.apache.wsif.WSIFService;
4 import org.apache.wsif.WSIFServiceFactory;
5 import org.apache.wsif.WSIFException;
6 import java.rmi.RemoteException JavaDoc;
7 import jms.client.stub.org.apache.xml.CheckAvailabilityPortType;
8
9 /**
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 JavaDoc[] args) {
21         try {
22
23             if (args.length != 2) {
24                 System.out.println(
25                     "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.newInstance();
31
32             // parse WSDL
33
WSIFService service =
34                 factory.getService(
35                     args[0],
36                     null,
37                     null,
38                     "http://xml.apache.org/axis/wsif/samples/jms/ServiceAvailability",
39                     "CheckAvailabilityPortType");
40             // create the stub
41
CheckAvailabilityPortType stub =
42                     (CheckAvailabilityPortType) service.getStub(
43                         CheckAvailabilityPortType.class);
44
45             // do the invocation
46
// args[1] is the zip code
47
String JavaDoc serviceAvailable = stub.checkAvailability(args[1]);
48             System.out.println(serviceAvailable);
49
50         } catch (WSIFException we) {
51             System.out.println(
52                 "Error while executing sample, received an exception from WSIF; details:");
53             we.printStackTrace();
54         } catch (RemoteException JavaDoc re) {
55             System.out.println(
56                 "Error while executing sample, received an exception due to remote invocation; details:");
57             re.printStackTrace();
58         }
59     }
60 }
61
Popular Tags