1 57 58 package clients.stockquote; 59 60 import org.apache.wsif.WSIFService; 61 import org.apache.wsif.WSIFServiceFactory; 62 import org.apache.wsif.base.WSIFServiceImpl; 63 import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis; 64 import org.apache.wsif.util.WSIFPluggableProviders; 65 66 import stockquote.wsifservice.StockquotePT; 67 68 80 public class Main { 81 82 private static void doit(StockquotePT service) throws Exception { 83 String name1 = "IBM"; 84 System.err.println(">> Getting quote for '" + name1 + "'"); 85 float quote = service.getQuote(name1); 86 System.err.println(">> Received quote: " + quote); 87 } 88 89 private static void usage() { 90 System.err.println( 91 "Usage: java " 92 + Main.class.getName() 93 + " portName wsdlLocation [soap|axis]"); 94 System.exit(1); 95 } 96 97 public static void main(String [] args) throws Exception { 98 if (args.length > 3) 99 usage(); 100 101 String protocol = null; 102 String portName = args.length > 0 ? args[0] : null; 103 if (args.length == 1 && (portName.equals("soap") || portName.equals("axis"))) { 104 protocol = portName; 105 portName = null; 106 } 107 108 String wsdlLocation = args.length > 1 ? args[1] : null; 109 if (args.length == 2 110 && (wsdlLocation.equals("soap") || wsdlLocation.equals("axis"))) { 111 protocol = wsdlLocation; 112 wsdlLocation = null; 113 } 114 115 protocol = args.length == 3 ? args[2] : ""; 116 if (!protocol.equals("") 117 && !protocol.equals("soap") 118 && !protocol.equals("axis")) 119 usage(); 120 121 if (protocol.equals("axis")) 122 WSIFPluggableProviders.overrideDefaultProvider( 123 "http://schemas.xmlsoap.org/wsdl/soap/", 124 new WSIFDynamicProvider_ApacheAxis()); 125 126 WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); 127 WSIFService service = factory.getService(wsdlLocation, null, null, "http://wsifservice.stockquote/", "StockquotePT"); 132 StockquotePT stub = null; 133 if (portName != null) { 134 System.err.println("\n\nUsing '" + portName + "' port:"); 135 stub = (StockquotePT) service.getStub(portName, StockquotePT.class); 136 doit(stub); 137 } else { 138 System.err.println("\n\nUsing SOAP port:"); 139 stub = (StockquotePT) service.getStub("SOAPPort", StockquotePT.class); 140 doit(stub); 141 142 System.err.println("\n\nUsing Java port:"); 143 stub = (StockquotePT) service.getStub("JavaPort", StockquotePT.class); 144 doit(stub); 145 } 146 147 if (protocol.equals("axis")) { WSIFPluggableProviders.overrideDefaultProvider( 149 "http://schemas.xmlsoap.org/wsdl/soap/", 150 null); 151 } 152 } 153 } 154 | Popular Tags |