I am trying to follow the this tutorial ( http://www.codeproject.com/KB/webservices/CallWebServiceFromHtml.aspx ) and learn to call a web service from a web page. However, I´m getting an error in the Firebug console:
service is not defined InitializeService() onload() event = load service.useService("http://tm.a...smx?WSDL", "TryggMedisinWebService");
This is the relevant code I´m using.
<script language="JavaScript">
function InitializeService() {
service.useService("http://tm.arnett.no/tryggmedisinwebservice/tryggmedisinwebservice.asmx?WSDL", "TryggMedisinWebService");
}
var spm, kategori, fylke;
function SendQuestio开发者_JAVA技巧n(){
spm = document.send_question.spm.value;
kategori = document.send_question.kategori.value;
fylke = document.send_question.fylke.value;
service.TryggMedisinWebService.callService("Send_Question", spm, kategori, fylke);
}
function ShowResult(){
alert(event.result.value);
}
</script>
<body onload="InitializeService()" id="service" style="behavior:url(<?php bloginfo('template_directory'); ?>/webservice.htc)" onresult="ShowResult()" <?php body_class(); ?>>
I would appreciate any help i can get on troubleshooting this.
Thanks!
This is using .htc
file and as far as I know it's supported only by IE browsers.
To have it work in other browsers, switch to using ordinary AJAX - for example jQuery provides excellent interface.
Here is link to good article explaining how to consume web service using jQuery:
http://www.c-sharpcorner.com/UploadFile/sridhar_subra/116/
Didn't personally test it, but from what I've seen the information there is accurate and to the point.
精彩评论