Scout/Tutorial/5.0/webservices/Integrate StockQuote service into CompanyService
Scout |
Wiki Home |
Website |
Download • Git |
Community |
Forums • Blog • Twitter • G+ |
Bugzilla |
Bugzilla |
@Override public CompanyFormData load(CompanyFormData formData) throws ProcessingException { SQL.selectInto("" + "SELECT NAME, " + " SYMBOL " + "FROM COMPANY " + "WHERE COMPANY_NR = :companyNr " + "INTO :name, " + " :symbol " , formData); // get stock qutoes from webservice StockQuoteServiceSoapWebServiceClient service = SERVICES.getService(StockQuoteServiceSoapWebServiceClient.class); // get port type to access webservice StockQuoteServiceSoap portType = service.getPortType(); // get quote for the given company StockQuote stockQuote = portType.getStockQuote(formData.getSymbol().getValue()); // load quotes into form data to be transferred to client formData.getSymbol().setValue(stockQuote.getStockTickerSymbol()); formData.getTradeTime().setValue(parseDateTime(stockQuote.getDate(), stockQuote.getTradeTime())); formData.getValueLast().setValue(parseDouble(stockQuote.getLastTrade())); formData.getValueOpen().setValue(parseDouble(stockQuote.getOpen())); formData.getValueLow().setValue(parseDouble(stockQuote.getDayLow())); formData.getValueHigh().setValue(parseDouble(stockQuote.getDayHigh())); formData.getVolume().setValue(parseLong(stockQuote.getVolume())); formData.getChange().setValue(parseDouble(stockQuote.getChangePercentage())); return formData; }