Options opts = new Options( args );
args = opts.getRemainingArgs();
if ( args == null ) {
System.err.println( "Usage: GetQuote <symbol>" );
System.exit(1);
}
symbol = args[0] ;
// useful option for profiling - perhaps we should remove before
// shipping?
String countOption = opts.isValueSet('c");
int count=1;
if ( countOption != null) {
count=Integer.valueOf(countOption).intValue();
System.out.println("Iterating " + count + " times");
}
URL url = new URL(opts.getURL());
String user = opts.getUser();
String passwd = opts.getPassword();
Service service = new Service();
Float res = new Float(0.0F);
for (int i=0; i<count; i++) {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( url );
call.setOperationName( new QName("urn:xmltoday-delayed-quotes", "getQuote") );
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_FLOAT );
// TESTING HACK BY ROBJ
if (symbol.equals("XXX_noaction")) {
symbol = "XXX";
}
call.setUsername( user );
call.setPassword( passwd );
Object ret = call.invoke( new Object[] {symbol} );
if (ret instanceof String) {
System.out.println("Received problem response from server: "+ret);
throw new AxisFault("", (String)ret, null, null);
}
res = (Float) ret;
}
return res.floatValue();