Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: complexsoap/client/stub/Run.java


1   package complexsoap.client.stub;
2   
3   import org.apache.wsif.WSIFService;
4   import org.apache.wsif.WSIFServiceFactory;
5   import org.apache.wsif.WSIFException;
6   import javax.xml.namespace.QName;
7   import java.rmi.RemoteException;
8   import complexsoap.client.stub.com.cdyne.ws.LatLongReturn;
9   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.println(
24                      "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.newInstance();
30  
31              // parse WSDL
32              WSIFService service =
33                  factory.getService(
34                      args[0],
35                      null,
36                      null,
37                      "http://ws.cdyne.com",
38                      "Zip2GeoSoap");
39  
40              // map types
41              service.mapType(
42                  new QName("http://ws.cdyne.com", "LatLongReturn"),
43                  Class.forName(
44                      "complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
45  
46              // create the stub
47              Zip2GeoSoap stub = (Zip2GeoSoap) service.getStub(Zip2GeoSoap.class);
48  
49              // do the invocation
50              // args[1] is the zip code
51              LatLongReturn zipInfo = stub.GetLatLong(args[1], "");
52  
53              System.out.println(
54                  "This zip code is in "
55                      + zipInfo.getCity()
56                      + ","
57                      + zipInfo.getStateAbbrev()
58                      + " in "
59                      + zipInfo.getCounty()
60                      + " county\n"
61                      + "It extends from longitude "
62                      + zipInfo.getFromLongitude()
63                      + " to longitude "
64                      + zipInfo.getToLongitude()
65                      + "\n and from latitude "
66                      + zipInfo.getFromLatitude()
67                      + " to latitude "
68                      + zipInfo.getToLatitude());
69  
70          } catch (WSIFException we) {
71              System.out.println(
72                  "Error while executing sample, received an exception from WSIF; details:");
73              we.printStackTrace();
74          } catch (RemoteException re) {
75              System.out.println(
76                  "Error while executing sample, received an exception due to remote invocation; details:");
77              re.printStackTrace();
78          } catch (ClassNotFoundException ce) {
79              System.out.println(
80                  "Error while executing sample, could not find required class complexsoap.client.stub.com.cdyne.ws.LatLongReturn; please add it to your classpath; details:");
81              ce.printStackTrace();
82          }
83      }
84  }