1 16 17 package samples.stock ; 18 19 import org.apache.axis.client.Call; 20 import org.apache.axis.client.Service; 21 import org.apache.axis.utils.Options; 22 23 import javax.xml.namespace.QName ; 24 import java.net.URL ; 25 26 public class GetQuote2 { 27 public String symbol ; 28 29 33 public float getQuote(String args[]) throws Exception { 34 Options opts = new Options( args ); 35 36 args = opts.getRemainingArgs(); 37 38 if ( args == null ) { 39 System.err.println( "Usage: GetQuote <symbol>" ); 40 System.exit(1); 41 } 42 43 44 45 QName servQN = new QName ("urn:xmltoday-delayed-quotes","GetQuoteService"); 46 QName portQN = new QName ("urn:xmltoday-delayed-quotes","GetQuoteJava"); 47 48 49 50 Service service = new Service( new URL ("file:GetQuote.wsdl"), servQN ); 51 Call call = (Call) service.createCall( portQN, "getQuote" ); 52 53 54 55 56 57 opts.setDefaultURL( call.getTargetEndpointAddress() ); 58 call.setTargetEndpointAddress( new URL (opts.getURL()) ); 59 60 61 62 Object result = call.invoke( new Object [] { symbol = args[0] } ); 63 64 return( ((Float ) result).floatValue() ); 65 } 66 67 public static void main(String args[]) { 68 try { 69 String save_args[] = new String [args.length]; 70 float val ; 71 GetQuote2 gq = new GetQuote2(); 72 73 74 75 System.out.println("Using Java binding in WSDL"); 76 System.arraycopy( args, 0, save_args, 0, args.length ); 77 val = gq.getQuote( args ); 78 System.out.println( gq.symbol + ": " + val ); 79 } 80 catch( Exception e ) { 81 e.printStackTrace(); 82 } 83 } 84 }; 85 | Popular Tags |