1 16 17 package test.wsdl.addrNoImplSEI; 18 19 import org.apache.axis.utils.Options; 20 21 import java.net.URL ; 22 23 24 25 32 public class Main { 33 static String name1; 34 static Address addr1; 35 static Phone phone1; 36 37 static { 38 name1 = "Purdue Boilermaker"; 39 addr1 = new Address(); 40 phone1 = new Phone(); 41 addr1.setStreetNum(1); 42 addr1.setStreetName("University Drive"); 43 addr1.setCity("West Lafayette"); 44 addr1.setState(StateType.IN); 45 addr1.setZip(47907); 46 phone1.setAreaCode(765); 47 phone1.setExchange("494"); 48 phone1.setNumber("4900"); 49 addr1.setPhone(phone1); 50 51 } 52 private static void printAddress (Address ad) { 53 if (ad == null) { 54 System.err.println ("\t[ADDRESS NOT FOUND!]"); 55 return; 56 } 57 System.err.println ("\t" + ad.getStreetNum() + " " + 58 ad.getStreetName()); 59 System.err.println ("\t" + ad.getCity() + ", " + ad.getState() + " " + 60 ad.getZip()); 61 Phone ph = ad.getPhone(); 62 System.err.println ("\tPhone: (" + ph.getAreaCode() + ") " + 63 ph.getExchange() + "-" + ph.getNumber()); 64 } 65 66 private static Object doit (AddressBookNoImplSEI ab) throws Exception { 67 ab.addEntry (name1, addr1); 68 Address resp = ab.getAddressFromName (name1); 69 70 73 resp = ab.getAddressFromName (name1); 74 75 try { 77 ab.addEntry(null, null); 78 throw new Exception ("Expected exception when calling addEntry with null params"); 79 } catch (org.apache.axis.AxisFault e) { 80 if ("java.lang.IllegalArgumentException".equals(e.getFaultString())) { 81 } else { 83 throw e; } 85 } 86 87 return resp; 88 } 89 90 public static void main (String [] args) throws Exception { 91 Options opts = new Options(args); 92 93 AddressBookNoImplSEIService abs = new AddressBookNoImplSEIServiceLocator(); 94 opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() ); 95 URL serviceURL = new URL (opts.getURL()); 96 97 AddressBookNoImplSEI ab1 = null; 98 if (serviceURL == null) { 99 ab1 = abs.getAddressBookNoImplSEI(); 100 } 101 else { 102 ab1 = abs.getAddressBookNoImplSEI(serviceURL); 103 } 104 Object ret = doit (ab1); 105 if (ret != null) { 106 throw new Exception ("non-session test expected null response, got "+ret); 107 } 108 109 AddressBookNoImplSEI ab2 = null; 110 if (serviceURL == null) { 111 ab2 = abs.getAddressBookNoImplSEI(); 112 } 113 else { 114 ab2 = abs.getAddressBookNoImplSEI(serviceURL); 115 } 116 ((AddressBookNoImplSEISoapBindingStub) ab2).setMaintainSession (true); 117 ret = doit (ab2); 118 if (ret == null) { 119 throw new Exception ("session test expected non-null response, got "+ret); 120 } 121 } 122 } 123 | Popular Tags |