01: package complexsoap.client.stub;
02:
03: import org.apache.wsif.WSIFService;
04: import org.apache.wsif.WSIFServiceFactory;
05: import org.apache.wsif.WSIFException;
06: import javax.xml.namespace.QName;
07: import java.rmi.RemoteException;
08: import complexsoap.client.stub.com.cdyne.ws.LatLongReturn;
09: import complexsoap.client.stub.com.cdyne.ws.Zip2GeoSoap;
10:
11: /**
12: * Simple class that Runs the SimpleSOAP sample using a pregenerated stub interface
13: * To use this class, provide a company stock symbol on the command line. WSIF
14: * should then invoke the SOAP service with this information, returning with a recent
15: * stockquote.
16: * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
17: */
18:
19: public class Run {
20: public static void main(String[] args) {
21: try {
22: if (args.length != 2) {
23: System.out
24: .println("Usage: java samples.complexsoap.client.stub.Run <wsdl location> <zip code>");
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.getService(args[0], null,
34: null, "http://ws.cdyne.com", "Zip2GeoSoap");
35:
36: // map types
37: service
38: .mapType(
39: new QName("http://ws.cdyne.com",
40: "LatLongReturn"),
41: Class
42: .forName("complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
43:
44: // create the stub
45: Zip2GeoSoap stub = (Zip2GeoSoap) service
46: .getStub(Zip2GeoSoap.class);
47:
48: // do the invocation
49: // args[1] is the zip code
50: LatLongReturn zipInfo = stub.GetLatLong(args[1], "");
51:
52: System.out.println("This zip code is in "
53: + zipInfo.getCity() + ","
54: + zipInfo.getStateAbbrev() + " in "
55: + zipInfo.getCounty() + " county\n"
56: + "It extends from longitude "
57: + zipInfo.getFromLongitude() + " to longitude "
58: + zipInfo.getToLongitude()
59: + "\n and from latitude "
60: + zipInfo.getFromLatitude() + " to latitude "
61: + zipInfo.getToLatitude());
62:
63: } catch (WSIFException we) {
64: System.out
65: .println("Error while executing sample, received an exception from WSIF; details:");
66: we.printStackTrace();
67: } catch (RemoteException re) {
68: System.out
69: .println("Error while executing sample, received an exception due to remote invocation; details:");
70: re.printStackTrace();
71: } catch (ClassNotFoundException ce) {
72: System.out
73: .println("Error while executing sample, could not find required class complexsoap.client.stub.com.cdyne.ws.LatLongReturn; please add it to your classpath; details:");
74: ce.printStackTrace();
75: }
76: }
77: }
|