spacer

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

home / experts / javascript / column105


Web Services, Part X: Consuming the StockQuote

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


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

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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