spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column105


Web Services, Part X: Consuming the StockQuote

Oracle DBA (IL)
Next Step Systems
US-IL-Lombard

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


Sending the Request

The init() function sends the request to the Web service. First, it establishes a short name for the Web service:

service.useService(
  "http://www.eggheadcafe.com/webservices/StockQuote/
  Stockquote.asmx?WSDL", "StockQuote");

Notice that "service" is the name of the DIV element to which we attached the webservice behavior (see Page 2). The useService() method is one of the webservice behavior's interface methods, and is defined in webservice.htc. The Web service Stockquote.asmx resides on the eggheadcafe server. We give it the short name StockQuote, and this is how we reference it when we actually call the Web service:


iCallID = service.StockQuote.callService
  ("GetQuote", symbols.value);

The callService() function is defined in webservice.htc. It expects a request name ("GetQuote") and its arguments. The GetQuote request expects a string with trade symbols, separated by blanks. This string is entered by the user in the input text field with ID="symbols" (see callstockquote.html), and is passed to the GetQuote request as symbols.value. Notice also how we keep the returned ID of callService() in iCallID. This is needed for matching the response from the Web service to the triggering request. Here is the full listing of the init() function:

function init() {
  service.useService(
    "http://www.eggheadcafe.com/webservices/StockQuote/
    Stockquote.asmx?WSDL", "StockQuote");
  iCallID = service.StockQuote.callService("GetQuote",
    symbols.value);
}


Next: How to write the response handling function

http://www.internet.com


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: March 11, 2002
Revised: March 11, 2002

URL: http://www.webreference.com/js/column105/3.html