views:

13

answers:

0

Hello. I'm somewhat new to web development. I was following some web services tutorials and everything went good, from writing the web services to displaying their results after you clicked on a button on a html page.

So I tried to run the service via javascript when the page loads, like this:

<html>
<head>
    <SCRIPT language="JavaScript">
    function SayHello()
    {        
        document.getElementById("HelloString").innerHTML="Starting Up..."
        //init
        try{
            service.useService("MyWebService.asmx?WSDL","SayHello");
        }catch(e){
            alert(e);
        }
        var iCallID;
        if (service.SayHello)
        {
                document.getElementById("HelloString").innerHTML="Loading..."    
                iCallID= service.SayHello.callService("SayHello");
        }
    }

    function GetSayHello()
    {
        if(event.result.error)
        {
              //Pull error info from event.result.errorDetail properties
            var xfaultcode   = event.result.errorDetail.code;
            var xfaultstring = event.result.errorDetail.string;
            var xfaultsoap   = event.result.errorDetail.raw;
            // Add code to handle specific error codes here
            document.getElementById("HelloString").innerHTML="Error: " + xfaultcode + " ; " + xfaultstring + " ; " + xfaultsoap;                            
        }
        else{
            document.getElementById("HelloString").innerHTML= event.result.value;            
        }
    }
    </SCRIPT>
</head>
<body onload="SayHello();">
    <div id="service" style="behavior:url(webservice.htc)" onresult="GetSayHello()"></div>
    <span id="HelloString">aaa</span>
</body>
</html>

But when I run it, I get the error "TypeError: service.UseService is not a function". I already certified webservice.htc is in the same folder of the html page... and I have no idea what could be causing this.

Thanks in advance ~

Conrado Clark