FileDocCategorySizeDatePackage
QuoteProxyService.javaAPI DocExample2333Tue Jan 15 12:09:50 GMT 2002javasoap.book.ch9.services

QuoteProxyService

public class QuoteProxyService extends Object

Fields Summary
Constructors Summary
public QuoteProxyService()

   
Methods Summary
public ProxyQuote[]getQuotes(java.lang.String[] symbols)

      Vector v = new Vector();
      int cnt = symbols.length;
      for (int i = 0; i < cnt; i++) {
         v.add(getStockQuote(symbols[i]));
      }
      cnt = v.size();
      ProxyQuote[] quotes = new ProxyQuote[cnt];
      for (int i = 0; i < cnt; i++) {
         quotes[i] = (ProxyQuote)v.elementAt(i);
      }

      return quotes;
   
ProxyQuotegetStockQuote(java.lang.String symbol)

URL url = new URL("http://mindstrm.com:8004/glue/urn:CorpDataServices");

      SOAPMappingRegistry smr = new SOAPMappingRegistry();

      BeanSerializer beanSer = new BeanSerializer();

      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://www.themindelectric.com/package/javasoap.book.ch9.services/", 
                 "Quote"),
                 RemoteQuote.class, beanSer, beanSer);
    
      Call call = new Call();
      call.setSOAPMappingRegistry(smr);
      call.setTargetObjectURI("XYZ");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

      String stock = symbol;

      Vector params = new Vector();
      params.addElement(new Parameter("stock", String.class, 
                                stock, null));
      call.setParams(params);
      
      call.setMethodName("getQuote");
      Response resp = call.invoke(url, "");
      ProxyQuote quote = new ProxyQuote();
      if (resp.generatedFault()) {
         throw new Exception("Service Call Failed");
      }
      else { 
         Parameter ret = resp.getReturnValue();
         RemoteQuote value = (RemoteQuote)ret.getValue();
         quote.setStockSymbol(value.get_symbol());
         quote.setLast(value.get_lastPrice());
         quote.setDiff(value.get_change());
         quote.setTime(value.get_timeStamp());
         quote.setVol(value.get_volume());
      }

      return quote;