01: package customfactory.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 customfactory.client.stub.com.themindelectric.www.NetXmethodsServicesStockquoteStockQuotePortType;
08:
09: /**
10: * Simple class that Runs the customfactory sample using a pregenerated stub interface
11: * To use this class, provide a company stock symbol
12: * on the command line. WSIF should then invoke the service with this information,
13: * using the port returned by the custom factory and returning with a recent stockquote.
14: * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
15: */
16:
17: public class Run {
18:
19: public static void main(String[] args) {
20: try {
21:
22: if (args.length != 2) {
23: System.out
24: .println("Usage: java customfactory.client.stub.Run <wsdl location> <company symbol>");
25: System.exit(1);
26: }
27:
28: // create a service factory
29: WSIFServiceFactory factory = WSIFServiceFactory
30: .newInstance();
31:
32: // parse WSDL
33: WSIFService service = factory
34: .getService(
35: args[0],
36: null,
37: null,
38: "http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/",
39: "net.xmethods.services.stockquote.StockQuotePortType");
40: // create the stub
41: // check if the user specified a preferred port
42: NetXmethodsServicesStockquoteStockQuotePortType stub = null;
43: stub = (NetXmethodsServicesStockquoteStockQuotePortType) service
44: .getStub(NetXmethodsServicesStockquoteStockQuotePortType.class);
45:
46: // do the invocation
47: // args[1] is the company symbol
48: float quote = stub.getQuote(args[1]);
49: System.out.println(quote);
50:
51: } catch (WSIFException we) {
52: System.out
53: .println("Error while executing sample, received an exception from WSIF; details:");
54: we.printStackTrace();
55: } catch (RemoteException re) {
56: System.out
57: .println("Error while executing sample, received an exception due to remote invocation; details:");
58: re.printStackTrace();
59: }
60: }
61: }
|