I wrote a web service in ASP.NET, it has this address:
http:
The web service has a GetMessage web method, it takes no parameters and returns a string.
Everything is fine with the web service, I call its methods from other ASP.NET applications or even from the Android application.
Server Code:
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { [WebMethod] public string GetMessage() { return "Hello World"; } }
Now I need to call the GetMessage web method from javascript.
html page: (on this web page there is no connection with the web service code, this is a completely different project! You can assume that it is written in notepad win)
... <body id="body1" onload="initialize()" style="behavior:url(webservice.htc)"> </body> ...
in the initialize () method, which I call:
... service_init(); processResult();
And there are the following functions:
function service_init() { body1.useService("http://localhost/RouteGen/Service.asmx?WSDL","TheService"); body1.TheService.callService("GetMessage"); } function processResult(result) { alert(result); }
So, I have a:
1) In IE, processResult() returns "undefined"
2) In Chrome and FireFox, it does not work at all (a simple notification after using the service does not appear)
Where is the problem? How to make javascript call a web method as usual and from different browsers?