The problem is that when I click on the button, I get an error: "Sys.Net.WebServiceFailedException: The server method '' failed with the following error:" .... and no error description
If you attach the debugger, you may find that the code is breaking in the proxy class somewhere like this:
if (((statusCode < 200) || (statusCode >= 300)) || errorObj) {
if (onFailure) {
if (!result || !errorObj) {
result = new Sys.Net.WebServiceError(false /*timedout*/, String.format(Sys.Res.webServiceFailedNoMsg, methodName), "", "");
}
result._statusCode = statusCode;
onFailure(result, userContext, methodName);
}
else {
// In debug mode, if no error was registered, display some trace information
var error;
if (result && errorObj) {
// If we got a result, we're likely dealing with an error in the method itself
error = result.get_exceptionType() + "-- " + result.get_message();
}
else {
// Otherwise, it's probably a 'top-level' error, in which case we dump the
// whole response in the trace
error = response.get_responseData();
}
// DevDiv 89485: throw, not alert()
the variable statusCode at the top of the code block is holding a HTTP Response code, in my case 404.
This function is the callback assigned to handle the async response. Directly above this function is the calling function that launches the async postback to the web service. I put a breakpoint on the line:
<div style="background-color: yellow;"> if (e) throw e;</div>
and had a look at the arguments object. In my case, I'm not passing in the correct reference to the web service. It's mapping "localhost/Webservice" to "/WebService" which is not the same thing as the web service is running on a different IIS directory.
This may not be an answer, but it may help in finding the problem.
I recently had the same error message and managed to solve it by adding a missing callback failure method parameter. I've posted it to
my blog but I've also pasted the main contents below for convenience:
This posting may help if you get an error message similar to the following when using Microsoft ASP.NET AJAX and
PageMethods to
call server-side code via JavaScript but only in Firefox (3 in my case), not in Internet Explorer:
The server method "MyServerMethod" failed with the following error:
<no errors shown>
There are various mentions of the above message with specific error messages but what makes the above unique is that no errors are listed, making it difficult to trace the source of the problem. After a bit of debugging and some
experimentation I discovered that I was missing the parameter defining the failure callback method:
function callMethod_Failure(errors, userContext, methodName) {
alert(errors.get_Message());
}
Unlike C#, JavaScript doesn't make all parameters mandatory so a missing parameter wasn't something I was used to looking out for! This combined with the different behaviour in the JavaScript engines of Internet Explorer and Firefox
made this a tricky bug to solve.
asp.net 2.0 ajax pagemethods javascript firefox callback error
eusebiu
Member
137 Points
80 Posts
Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 07, 2008 11:03 AM|LINK
Hello...
Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.
[WebMethod] public static string aaa(int i) { Thread.Sleep(1000); return i.ToString(); } [WebMethod] public static string aaa1(int i) { Thread.Sleep(1000); return i.ToString(); }The problem is that when I click on the button, I get an error: "Sys.Net.WebServiceFailedException: The server method '' failed with the following error:" .... and no error description
Can someone tell me how to workaround this issue?
Thanks
P.S. In Firefox 2.0.0.16 this code works....
ajax WebServiceFailedException
itsumapathyk
Participant
1550 Points
358 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 07, 2008 11:09 AM|LINK
www.codeplex.com/phpmsajax/WorkItem/View.aspx?WorkItemId=4997
dotnetforum.lk/forums/p/8954/31273.aspx
forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3592022&SiteID=1
www.CodeCollege.NET,www.interviewsguru.com,The Encyclopedia of Sites ,www.thekumbakonam.com
eusebiu
Member
137 Points
80 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 07, 2008 11:18 AM|LINK
I've already read thouse posts... but no solution. BTW... I know how to search on Google...
Anybody else?
daveyboy79
Member
2 Points
1 Post
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 07, 2008 03:31 PM|LINK
Hi,
If you attach the debugger, you may find that the code is breaking in the proxy class somewhere like this:
if (((statusCode < 200) || (statusCode >= 300)) || errorObj) {
<div style="background-color: yellow;"> throw Sys.Net.WebServiceProxy._createFailedError(methodName, String.format(Sys.Res.webServiceFailed, methodName, error));</div>if (onFailure) {
if (!result || !errorObj) {
result = new Sys.Net.WebServiceError(false /*timedout*/, String.format(Sys.Res.webServiceFailedNoMsg, methodName), "", "");
}
result._statusCode = statusCode;
onFailure(result, userContext, methodName);
}
else {
// In debug mode, if no error was registered, display some trace information
var error;
if (result && errorObj) {
// If we got a result, we're likely dealing with an error in the method itself
error = result.get_exceptionType() + "-- " + result.get_message();
}
else {
// Otherwise, it's probably a 'top-level' error, in which case we dump the
// whole response in the trace
error = response.get_responseData();
}
// DevDiv 89485: throw, not alert()
}
}
the variable statusCode at the top of the code block is holding a HTTP Response code, in my case 404.
This function is the callback assigned to handle the async response. Directly above this function is the calling function that launches the async postback to the web service. I put a breakpoint on the line:
var e = Function._validateParams(arguments, [
<div style="background-color: yellow;"> if (e) throw e;</div>{name: "servicePath", type: String},
{name: "methodName", type: String},
{name: "useGet", type: Boolean, optional: true},
{name: "params", mayBeNull: true, optional: true},
{name: "onSuccess", type: Function, mayBeNull: true, optional: true},
{name: "onFailure", type: Function, mayBeNull: true, optional: true},
{name: "userContext", mayBeNull: true, optional: true},
{name: "timeout", type: Number, optional: true}
]);
and had a look at the arguments object. In my case, I'm not passing in the correct reference to the web service. It's mapping "localhost/Webservice" to "/WebService" which is not the same thing as the web service is running on a different IIS directory.
This may not be an answer, but it may help in finding the problem.
Regards,
David E
eusebiu
Member
137 Points
80 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 07, 2008 03:47 PM|LINK
Hello...
I've been watching the parameters and the servicePath is "/WebApplication1/Default.aspx", method name is "aaa" and params is "9"...
I think it's there's limit of requests that haven't been answered yet... because if I remove the Thread.Sleep(1000) method, it works fine.
eusebiu
Member
137 Points
80 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 09, 2008 07:52 AM|LINK
On VS TS 2008 the exception isn't raised... only in VS 2008 Professional Edition.... and I wonder why...
tjrobinson.net
Member
11 Points
12 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Dec 24, 2008 05:06 PM|LINK
I recently had the same error message and managed to solve it by adding a missing callback failure method parameter. I've posted it to my blog but I've also pasted the main contents below for convenience:
asp.net 2.0 ajax pagemethods javascript firefox callback error
leosuaar
Member
8 Points
4 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Aug 20, 2010 09:19 PM|LINK
I am not sure, but I remember that error; the problem could be in next line:
xmen
Member
99 Points
207 Posts
Re: Sys.Net.WebServiceFailedException: The server method '' failed with the following error:
Nov 03, 2010 02:28 AM|LINK
Well, this is 2 years old question but you must handle onFailed event as well to avoid that crash.
something like this
PageMethods.aaa(i,
function(res, ctrl){
document.getElementById('displayspan').innerHTML+=res.toString() + ' ';
},
function(err){ } //leave it empty if you dont want to show error else use err.get_message()
);
C# Programmer