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 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 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 30 31 WSIFService service = 33 factory.getService( 34 args[0], 35 null, 36 null, 37 "http://ws.cdyne.com", 38 "Zip2GeoSoap"); 39 40 service.mapType( 42 new QName ("http://ws.cdyne.com", "LatLongReturn"), 43 Class.forName( 44 "complexsoap.client.stub.com.cdyne.ws.LatLongReturn")); 45 46 Zip2GeoSoap stub = (Zip2GeoSoap) service.getStub(Zip2GeoSoap.class); 48 49 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 } 85 | Popular Tags |