1 package complexsoap.client.dynamic; 2 3 import javax.xml.namespace.QName ; 4 5 import org.apache.wsif.WSIFMessage; 6 import org.apache.wsif.WSIFOperation; 7 import org.apache.wsif.WSIFPort; 8 import org.apache.wsif.WSIFService; 9 import org.apache.wsif.WSIFServiceFactory; 10 11 import complexsoap.client.stub.com.cdyne.ws.LatLongReturn; 12 13 public class Run { 14 public static void main(String [] args) throws Exception { 15 16 if (args.length != 2) { 18 System.out.println( 19 "Usage: java complexsoap.client.dynamic.Run <wsdl location> <zip code>"); 20 System.exit(1); 21 } 22 23 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 25 WSIFService service = 26 factory.getService( 27 args[0], 28 null, 29 null, 30 "http://ws.cdyne.com", 31 "Zip2GeoSoap"); 32 33 service.mapType( 35 new QName ("http://ws.cdyne.com", "LatLongReturn"), 36 Class.forName( 37 "complexsoap.client.stub.com.cdyne.ws.LatLongReturn")); 38 39 WSIFPort port = service.getPort(); 41 42 WSIFOperation operation = port.createOperation("GetLatLong"); 44 45 WSIFMessage input = operation.createInputMessage(); 47 WSIFMessage output = operation.createOutputMessage(); 48 WSIFMessage fault = operation.createFaultMessage(); 49 50 input.setObjectPart("zipcode", args[1]); 52 input.setObjectPart("LicenseKey", ""); 53 54 if (operation.executeRequestResponseOperation(input, output, fault)) { 56 LatLongReturn zipInfo = 59 (LatLongReturn) output.getObjectPart("GetLatLongResult"); 60 System.out.println( 61 "This zip code is in " 62 + zipInfo.getCity() 63 + "," 64 + zipInfo.getStateAbbrev() 65 + " in " 66 + zipInfo.getCounty() 67 + " county\n" 68 + "It extends from longitude " 69 + zipInfo.getFromLongitude() 70 + " to longitude " 71 + zipInfo.getToLongitude() 72 + "\n and from latitude " 73 + zipInfo.getFromLatitude() 74 + " to latitude " 75 + zipInfo.getToLatitude()); 76 } else { 77 System.out.println("Invocation failed"); 78 } 80 } 81 } 82 | Popular Tags |