3
从javascript调用WebService/C#时出现奇怪的错误。服务器方法'methodname'失败
服务器方法'GetGoogleToken'失败。 没有详细信息,没有堆栈跟踪。 在服务器上,我设置了断点 - 一切正常,并且我正在返回字符串(可能更简单吗?)
此外,当我使用浏览器测试环境调用它时,方法正常工作。
这里是方法:
[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)
{
// no errors happening on server side
throw new ApplicationException("Error in GetGoogleToken", ex);
}
}
我的类属性:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
我的javascript:
Namespace.WebServices.ContactsImport.GetGoogleToken(login, password, ImportGoogle.authenticated, OnAjaxRequest_Error);
我也注意到,这个错误发生之前服务器返回的结果。 (例如我有断点)
谢谢。我有类似的问题。我有一个类型提交的输入,而不是按钮,在Chrome上,它发射了一个回传。 – bnieland 2011-02-22 15:15:22