spacer

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

home / experts / javascript / column112


JScript .NET, Part VI: Creating IE Web Services

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

The GUI for Consuming Web Services

We have explained in Column 106 how to consume Web services through Microsoft Internet Explorer. There are three HTML items you need to add to your page for it to consume Web services:

  • onload="init()". Add this event handler to your BODY tag. For example:
  • <BODY BGCOLOR="#ffffff" onload="init()">

  • Instantiate the webservice behavior. You can share this behavior among all Web services you consume from your page:
  • 
    <DIV ID="myWebService"
      STYLE="behavior:url(webservice.htc)">
      </DIV>

  • GUI. Implement some way to collect user parameters and display the results. Simple INPUT elements will do.

We implemented both consumers with TABLEs. The add TABLE consists of four rows. You enter the first and second integers in the first and second rows, respectively, where we use INPUT fields. The third line is for putting a total ruler and a button to invoke the addition. The fourth line displays the result, by way of a DIV element: we update its innerHTML. Here is the add TABLE:

<TABLE BORDER="0">
  <TR><TD>Enter First Number:</TD><TD><INPUT SIZE="4"
    TYPE="text" ID="first" STYLE="text-align:'right'">
  </TD></TR>
  <TR><TD>Enter Second Number:</TD><TD><INPUT SIZE="4"
    TYPE="text" ID="second" STYLE="text-align:'right'">
  </TD></TR>
  <TR><TD align="right"><INPUT VALUE="Add" TYPE="button"
    onclick="addNumbers();"></TD><TD><HR></TD></TR>
  <TR><TD></TD><TD><DIV ID="theResult1"
    STYLE="text-align:'right'"></DIV></TD></TR>
</TABLE>

Notice the ID of the various fields. The ID of the first number field is "first", the ID of the second number field is "second", and the ID of the result DIV is "theResult1". The Add button invokes the addNumbers() function when clicked.

The isprime TABLE has two rows. The first row includes an entry field for the number to be tested and a button to invoke the check. The second row includes a DIV element that displays the answer, via an innerHTML update. The ID of the input field is "testValue" and the ID of the result DIV is "theResult2". The button calls isPrimeNumber() when clicked. Here is the HTML code:

<TABLE BORDER="0">
  <TR>
    <TD>Enter a number:</TD>
    <TD><INPUT SIZE="4" TYPE="text"
      ID="testValue" VALUE="0">
    </TD>
    <TD>&nbsp;</TD>
    <TD><INPUT VALUE="Click here to check if prime"
	 TYPE="button" onclick="isPrimeNumber();"></TD>
  </TR>
  <TR><TD COLSPAN=4><DIV ID="theResult2"></DIV></TD>
  </TR>
</TABLE>

Next: How to script a page that consumes Web services


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: June 17, 2002
Revised: June 17, 2002

URL: http://www.webreference.com/js/column112/5.html