Hi,
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 ( I see the webservices, ... So I'm sure this page is ok.
Now I'm trying to consume this webservice using an HTML doc with JavaScript.
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 1.0.1.810) and there is a public method called useService.
This is my testing code:
The first init() service triggers the error... Anybody knows what I'm missing here?
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 ( I see the webservices, ... So I'm sure this page is ok.
Now I'm trying to consume this webservice using an HTML doc with JavaScript.
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 1.0.1.810) and there is a public method called useService.
This is my testing code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test service</title>
<script type="text/javascript" language="javascript">
function init()
{
try
{
websrvCaller.useService("[URL unfurl="true"]http://intranet/testservices/service1.asmx?wsdl","myService");[/URL]
}
catch (e)
{
alert(e);
}
}
function test()
{
websrvCaller.myService.callService(myCallback,"HelloWorld", "Asynchronous Call");
}
function myCallback(res)
{
if (!res.error)
{
alert("Successful call. Result is " + res.value);
}
else
{
alert("Unsuccessful call. Error is " + res.errorDetail.string);
}
}
</script>
</head>
<body ID="websrvCaller" onload="init()" STYLE="behavior:url(webservice.htc);" >
<input type="button" id="btnTest" value="test" onclick="test();" />
</body>
</html>
The first init() service triggers the error... Anybody knows what I'm missing here?