Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Scout/Tutorial/3.9/webservices/Integrate StockQuote service into CompanyService

< Scout‎ | Tutorial‎ | 3.9‎ | webservices

The Scout documentation has been moved to https://eclipsescout.github.io/.

@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;
}

Back to the top