【发布时间】:2010-12-20 18:54:24
【问题描述】:
从 javascript 调用 WebService/C# 时出现奇怪的错误。
服务器方法“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);
我还注意到,该错误发生在服务器返回结果之前。 (例如我有断点)
【问题讨论】:
标签: javascript asp.net-ajax web-services