I have a weird error when calling WebService / C # from javascript.
Failed to execute GetGoogleToken server method. No details, no stacktrace. On the server, I set a breakpoint - everything works smoothly, and I save the line (what could be easier?)
Also, the method works great when I call it using the browser testing environment.
Here is a way:
[WebMethod]
public string GetGoogleToken(string login, string password)
{
try
{
string token = string.Empty;
if (!String.IsNullOrEmpty(login) && !String.IsNullOrEmpty(password))
{
ContactsService service = new ContactsService("...");
service.setUserCredentials(login, password);
token = service.QueryAuthenticationToken();
}
return token;
}
catch (Exception ex)
{
throw new ApplicationException("Error in GetGoogleToken", ex);
}
}
My class attributes:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
my javascript:
Namespace.WebServices.ContactsImport.GetGoogleToken(login, password, ImportGoogle.authenticated, OnAjaxRequest_Error);
I also noticed that an error occurs before the server returns. (e.g. I have a breakpoint)
source
share