My web service is written in C# and ASP.NET. The name of the service is
Service1. The web methods exposed under this service is "WebAdd". This
webmethod takes two integers as an input and returns the result of
addition of both the integers.
I have this service hosted in a folder called "MathOps" in my localhost
(IIS Webserver). I want to write a simple html file, which has two text
boxes to take those inputs and upon clicking an "Add" Button, it prints
the result to the screen.
I have accomplished this task using IE with the help of HTML Component
for web serrvices (WebServices.htc) provided by Microsoft. I researched
a lot on calling web services from netscape/mozilla based browsers but
to no avail. I have visited the site you told me, but I am surprised to
find out their examples dont run on Firefox 1.0 I havent tried other
mozilla based browsers though.
My HTML file looks like this (when I use webservices.htc for IE)
*************************************************************************
<HTML>
<HEAD>
<TITLE>Consuming the ADD Web Service</TITLE>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function init() {
myWebService.useService("
http://localhost/MathOps/Service1.asmx?WSDL",
"simpleCalcWebService");
}
function addNumbers(a, b) {
myWebService.simpleCalcWebService.callService(addResult, "WebAdd",
first.value, second.value);
}
function addResult(result) {
theResult1.innerHTML = result.value;
}
// -->
</SCRIPT>
</HEAD>
<BODY onload="init()">
<DIV ID="myWebService" STYLE="behavior:url(webservice.htc)"></DIV>
<TABLE BORDER="0">
<TR><TD>Number 1: </TD><TD><INPUT SIZE="4" TYPE="text" ID="first"
STYLE="text-align:'right'"></TD></TR>
<TR><TD>Number 2: </TD><TD><INPUT SIZE="4" TYPE="text" ID="second"
STYLE="text-align:'right'"></TD></TR>
<TR><TD><HR></TD><TD><INPUT VALUE="Add" TYPE="button"
onclick="addNumbers();"></TD></TR>
<TR><TD>Result: </TD><TD><DIV ID="theResult1"
STYLE="text-align:'right'"></DIV></TD></TR>
</TABLE>
</BODY>
</BODY>
</HTML>
**************************************************************
Please let me know if you need more info on this..
Thanks,
Nifty