Hi

I am trying to call my BMI webservice to a html page which calculates and return the result, I have the following code but it is not working.

<html>
  <head>
   <title>Body Mass Calculator</title>
    <script language="JavaScript">
     function InitializeService(){
      service.useService(http://localhost:57955/BMI.asmx, 
	"BMI");
     }
     var doubleFeet, doubleInches, doubleWeight;
     function GetBMI(){
      doubleFeet = document.DemoForm.doubleFeet.value;
      doubleInches = document.DemoForm.doubleInches.value;
      doubleWeight = document.DemoForm.doubleWeight.value;
      service.BMI.callService("GetBMI", doubleFeet, doubleInches, doubleWeight);
     }
     function ShowResult(){
    alert(event.result.value);
      }
     </script>
    </head>
     <body onload="InitializeService()" id="service" 
	style="behavior:url(webservice.htc)" onresult="ShowResult()">
      <form name="DemoForm">
       Feet : <input type="text" name="doubleFeet"/>
       Inches : <input type="text" name="doubleInches"/>
       Weight : <input type="text" name="doubleWeight"/>
       <button onclick="GetBMI()">Get BMI</button>
      </form>
     </body>
 </html>

This is the line you are using to connect to the service.

service.useService(http://localhost:57955/BMI.asmx, "BMI");

Try this one.

service.useService(http://www.beetledev.com/webservices/bmiservice.asmx, "BMI"

This is your code.
service.BMI.callService("GetBMI", doubleFeet, doubleInches, doubleWeight);
This is from Microsoft.

iCallID = sElementID.sFriendlyName.callService( [oCallHandler], fo, oParam)
sElementID	 Required. The id of the element to which the WebService behavior is attached.
sFriendlyName	 Required. The friendly name for the Web Service, which is defined by calling the useService method.
oCallHandler	 Optional. The name of a script callback function that handles the results returned from this instance of the method call.
fo	 Required. One of the following possible values.
strFuncName
A String representing the name of the remote function being called. The String must be bounded by single or double quotation marks.
objCall
A call object, which has the necessary properties defined to call a remote function.
oParam	 Required. One or more comma-delimited parameters, which are passed to the method name specified by fo.

Look at the args you are calling with and compare them to what Microsoft says. Clean this up and I think everything will work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.