01: package simplesoap.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 simplesoap.client.stub.com.themindelectric.www.NetXmethodsServicesStockquoteStockQuotePortType;
08:
09: /**
10: * Simple class that Runs the SimpleSOAP sample using a pregenerated stub interface
11: * To use this class, provide a company stock symbol on the command line. WSIF
12: * should then invoke the SOAP service with this information, returning with a recent
13: * 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 simplesoap.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: NetXmethodsServicesStockquoteStockQuotePortType stub = (NetXmethodsServicesStockquoteStockQuotePortType) service
42: .getStub(NetXmethodsServicesStockquoteStockQuotePortType.class);
43:
44: // do the invocation
45: // args[1] is the company symbol
46: float quote = stub.getQuote(args[1]);
47: System.out.println(quote);
48:
49: } catch (WSIFException we) {
50: System.out
51: .println("Error while executing sample, received an exception from WSIF; details:");
52: we.printStackTrace();
53: } catch (RemoteException re) {
54: System.out
55: .println("Error while executing sample, received an exception due to remote invocation; details:");
56: re.printStackTrace();
57: }
58: }
59: }
|