I'm trying to consume a webservice (default HelloWorld created in Visual Studio 2010 / ASP.NET web application)
The .asmx file is located on my local network. When I enter the URL in my browser (http://intranet/testservices/service1.asmx
), I see the webservices, ... So I'm sure this page is ok.
I looked for some tutorials on the net, all the examples say I should place "webservice.htc" in the same folder as my HTML doc (and refer to it using the 'id' and 'style' attribute in an element - I used it in the body tag)
However, when calling ".useService" I receive an error "TypeError: Object doesn't support property or method 'useService'" (tested with IE9, Chrome16, FF5.0)
I looked into the webservice.htc file (version 22.214.171.1240) and there is a public method called useService (when I use Visual Studio and debug the code, I see it enters the useService function in the htc file - but the error remains)
This is my testing code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
websrvCaller.myService.callService(myCallback,"HelloWorld", "Asynchronous Call");
alert("Successful call. Result is " + res.value);
alert("Unsuccessful call. Error is " + res.errorDetail.string);
<body ID="websrvCaller" onload="init()" STYLE="behavior:url(webservice.htc);" >
<input type="button" id="btnTest" value="test" onclick="test();" />
The first init() service triggers the error... Anybody knows what I'm missing here?