Call.addTransportPackage("samples.transport");
Call.setTransportForProtocol("tcp", TCPTransport.class);
Options opts = new Options( args );
args = opts.getRemainingArgs();
if ( args == null ) {
System.err.println( "Usage: GetQuote <symbol>" );
System.exit(1);
}
String namespace = "urn:xmltoday-delayed-quotes";
symbol = args[0] ;
EngineConfiguration defaultConfig =
(new DefaultEngineConfigurationFactory()).
getClientEngineConfig();
SimpleProvider config = new SimpleProvider(defaultConfig);
SimpleTargetedChain c = new SimpleTargetedChain(new TCPSender());
config.deployTransport("tcp", c);
Service service = new Service(config);
Call call = (Call)service.createCall();
call.setTransport(new TCPTransport());
call.setTargetEndpointAddress( new URL(opts.getURL()) );
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( opts.getUser() );
call.setPassword( opts.getPassword() );
// 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");
}
Float res = new Float(0.0F);
for (int i=0; i<count; i++) {
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();