I am trying to call the method below through a jQuery Ajax call (see below). I can hit the AjaxMethods.aspx page without any problems but for some reason I keep getting a 404 error when trying to hit the web method.
Has anyone got any ideas?
Thanks in advance.
[WebMethod()] public static string sayHello() { return "hello "; }
And the problem is the translation of the URL to the lowercase.
It means that when you call AjaxMethods.aspx/sayHello it throws an exception that the method is case sensitive, because umbraco translates the URL to ajaxmethods.aspx/sayhello
System.ArgumentException: Invalid method name 'getbalance', method names are case sensitive. The method name 'GetBalance' with the same name but different casing was found.
Parameter name: methodName
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
apparently this is just a bit of a hack with executing the web service directly from within the browser, aka if you browse to www.smspunkt.dk/.../GetBalance. I have added the lowercase alternative to pretty much all of my web service so I can call them in the browser if needed for debugging purposes, however when I call them from code I still use camel case and it works fine.
JQuery Ajax Serverside Method Call
I am trying to call the method below through a jQuery Ajax call (see below). I can hit the AjaxMethods.aspx page without any problems but for some reason I keep getting a 404 error when trying to hit the web method.
Has anyone got any ideas?
Thanks in advance.
Have you tried using an absolute URL in your jQuery script?
Thanks for the reply Dan, here is what I have tried:
I've never had page methods working with Umbraco, essentially I think the root problem with that it's coming in via a ASPX page.
You're better off using Web Services (ASMX).
The problem I guess is stated in this topic http://forum.umbraco.org/yaf_postst5698_Problems-with-webservices-Umbraco-V4.aspx
And the problem is the translation of the URL to the lowercase.
It means that when you call AjaxMethods.aspx/sayHello it throws an exception that the method is case sensitive, because umbraco translates the URL to ajaxmethods.aspx/sayhello
Please correct me if i am wrong.
Does anyone found a solution for that issue?
I am running umbraco 4.5 on iis7
and get the following error when I call
http://www.smspunkt.dk/webservices/SMSService.asmx/GetBalance
Does anyone know how to fix it?
Hi Julius,
Try setting the MessageName field on the web method attribute which is all lowercase, like so:
[WebMehod(MessageName = "mywebmethodname")]
(http://msdn.microsoft.com/en-us/library/byxd99hx(VS.71).aspx#vbtskusingwebmethodattributemessagename)
I'm afraid I've forgotten why this lower/uppercase issue occurs, but this should help.
Sascha
Hey Sascha,
thanks for the answer.
Unfortunately the solution is not suitable, because then my customers need to change method name to the lower-case.
Do you know if it is possible to solve it any other way?
/Julius
Hi Julius,
apparently this is just a bit of a hack with executing the web service directly from within the browser, aka if you browse to www.smspunkt.dk/.../GetBalance. I have added the lowercase alternative to pretty much all of my web service so I can call them in the browser if needed for debugging purposes, however when I call them from code I still use camel case and it works fine.
Maybe it's worth giving it a shot in your system?
Sascha
Well, it could be an option, but I don't want to cause problems to customers.
Therefore I think there should be a fix for this.
I have put an issue on codeplex tracking system. http://umbraco.codeplex.com/workitem/28123
If anybody found any solutions, please share :)
is working on a reply...