01: package multibinding.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 multibinding.client.stub.com.themindelectric.www.NetXmethodsServicesStockquoteStockQuotePortType;
08:
09: /**
10: * Simple class that Runs the multibinding sample using a pregenerated stub interface
11: * To use this class, provide a company stock symbol and an optional port preference
12: * on the command line. WSIF should then invoke the service with this information,
13: * using the appropriate port 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 && args.length != 3) {
23: System.out
24: .println("Usage: java multibinding.client.stub.Run <wsdl location> <company symbol> [StockQuoteJavaPort|StockQuoteSOAPPort]");
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: if (args[2] != null)
44: stub = (NetXmethodsServicesStockquoteStockQuotePortType) service
45: .getStub(
46: args[2],
47: NetXmethodsServicesStockquoteStockQuotePortType.class);
48: else
49: stub = (NetXmethodsServicesStockquoteStockQuotePortType) service
50: .getStub(NetXmethodsServicesStockquoteStockQuotePortType.class);
51:
52: // do the invocation
53: // args[1] is the company symbol
54: float quote = stub.getQuote(args[1]);
55: System.out.println(quote);
56:
57: } catch (WSIFException we) {
58: System.out
59: .println("Error while executing sample, received an exception from WSIF; details:");
60: we.printStackTrace();
61: } catch (RemoteException re) {
62: System.out
63: .println("Error while executing sample, received an exception due to remote invocation; details:");
64: re.printStackTrace();
65: }
66: }
67: }
|