FileDocCategorySizeDatePackage
StockPriceApp.javaAPI DocExample1306Tue Feb 26 12:15:46 GMT 2002javasoap.book.ch4

StockPriceApp

public class StockPriceApp extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

      
      URL url = 
        new URL(
          "http://georgetown:8080/soap/servlet/rpcrouter");
    
      Call call = new Call();
      call.setTargetObjectURI("urn:StockPriceService");
      
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
      String stock = "MINDSTRM";
      String currency = "USD";
      Vector params = new Vector();
      params.addElement(new Parameter("stock", 
                         String.class, stock, null));
      params.addElement(new Parameter("currency", 
                         String.class, currency, null));
      call.setParams(params);
      
      try {
         call.setMethodName("getPrice");
         Response resp = call.invoke(url, "");
         Parameter ret = resp.getReturnValue();
         Object value = ret.getValue();
         System.out.println("Price is " + value);
      }
      catch (SOAPException e) {
         System.err.println("Caught SOAPException (" +
                         e.getFaultCode() + "): " +
                         e.getMessage());
      }