It is supposed to send shopping cart id and return order id. It works in non umbraco site, when imported into umbraco as a part of an asp.net page it fails with xhr.status 500 which will translate into internal server error.
Both the page making call and oredrs.asmx are added to umbraco reserved urls. The umbraco version 4.021 is installed on the site.
Any help with this problem will be greatly appreciated.
If it throws a 500-error, maybe you can get additional info from the event-log or from the umbracoLog-table. Other than that, I'm pretty much running out of options!
Should have checked event log long time ago. It reads as follows: Exception message: Only Web services with a [ScriptService] attribute on the class definition can be called from script.
Well I do have it on my class:
... Imports System.Web.Script.Services
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.com/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ <ScriptService()> _ Public Class Orders1 Inherits System.Web.Services.WebService
The company policy to use VB, I use both no probs I did have WebMethod attribute, not the ScriptMethod though, it is now in place to no avail.
I just wonder the site is compiled on 3.5 platform, I am using Linq, and braco site web.config is tuned for asp.net 2.0, would that be an issue, maybe referencing different assembly or similar?
<System.Web.Script.Services.ScriptService()> is a class attribute, cann'ot be applied to the method.
I did search on the error message and part of the stack in Google:
Only Web services with a [ScriptService] attribute on the class definition can be called from script.System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods)
I would say according to some of the results that the issue may be in web.config settings, but I can't be sure as yet.
From the top of my head, only the attribute on the class is not enough. Now I'm not sure which one solved my problem, adding the webmethod or the scriptmethod.
Only thing I added to my web.config was the piece I posted earlier. Other than that, I made no changes. I think you should look in the code. Mainly because you get a 500-error (that makes me think the page get called, but somehow throws an error)
Well I have all that as well, I found out what that was, I had to change all the settings in web.config in connection with ajax to reference ASP.NET 3.5 assemblies.
That 500 error is a red herring.
Anyway without your help I may not have solved it by now, I tahnk you for that.
Bedankt. Grooten an iederen in Flevoland from Engeland, daar ben ik nooit geweest.
Ah, didn't think that it would matter, but apparantly it does. Good to know! (I wish I advised you to use the 3.5-configfile to check if it would matter, but I really thought it wouldn't)
Jquery ajax calls
Hi
The following jquery code makes a call to the webservice:
$.ajax({ type: "POST",
url: "/Orders.asmx/InsertOrder",
data: "{cartID:" + cartID + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$('#OrderID').val(msg.d);
},
error: function(xhr) {
alert(xhr.status);
}
});
It is supposed to send shopping cart id and return order id. It works in non umbraco site, when imported into umbraco as a part of an asp.net page it fails with xhr.status 500 which will translate into internal server error.
Both the page making call and oredrs.asmx are added to umbraco reserved urls. The umbraco version 4.021 is installed on the site.
Any help with this problem will be greatly appreciated.
Try adding these lines in your web.config (in system.web-part):
Bedankt, geen geluk.
Thanx Peter it did not work.
Just to clear, I tested webservice localy and it works ok. I also tried setting full path to orders.asmx (hardcoded and via js), it did not work.
Hm ok, not exactly what I expected.
Are you able to test the webservice remotely? Or does it only work locally?
Yep works remotely, I made a test project with a webreference to orders.asmx and everything works ok.
Must be something that prevents a script call.
Perhaphs the data that gets posted to the webservice is not correct then so it throws a 500?
Debugged js data, also use a simple alert box to check the value, aalso checked database values, the value passed for cartID seems to be correct.
If it throws a 500-error, maybe you can get additional info from the event-log or from the umbracoLog-table. Other than that, I'm pretty much running out of options!
Het is zo lastig.
Should have checked event log long time ago. It reads as follows:
Exception message: Only Web services with a [ScriptService] attribute on the class definition can be called from script.
Well I do have it on my class:
...
Imports System.Web.Script.Services
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.com/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
<ScriptService()> _
Public Class Orders1
Inherits System.Web.Services.WebService
...
Hm, now you mention it, I did have that same issue. I'm using C# though, but this is what my class looks like:
The company policy to use VB, I use both no probs I did have WebMethod attribute, not the ScriptMethod though, it is now in place to no avail.
I just wonder the site is compiled on 3.5 platform, I am using Linq, and braco site web.config is tuned for asp.net 2.0, would that be an issue, maybe referencing different assembly or similar?
I think I spotted the point where it goes wrong.
You set the ScriptService on the Class. You also need to set the ScriptService on your procedure (InsertOrder) to make it work.
<System.Web.Script.Services.ScriptService()> is a class attribute, cann'ot be applied to the method.
I did search on the error message and part of the stack in Google:
Only Web services with a [ScriptService] attribute on the class definition can be called from script.System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods)
I would say according to some of the results that the issue may be in web.config settings, but I can't be sure as yet.
Let me explain what I have in my code:
On the class, I have this:
On the method, I have this:
From the top of my head, only the attribute on the class is not enough. Now I'm not sure which one solved my problem, adding the webmethod or the scriptmethod.
Only thing I added to my web.config was the piece I posted earlier. Other than that, I made no changes. I think you should look in the code. Mainly because you get a 500-error (that makes me think the page get called, but somehow throws an error)
Well I have all that as well, I found out what that was, I had to change all the settings in web.config in connection with ajax to reference ASP.NET 3.5 assemblies.
That 500 error is a red herring.
Anyway without your help I may not have solved it by now, I tahnk you for that.
Bedankt. Grooten an iederen in Flevoland from Engeland, daar ben ik nooit geweest.
Ah, didn't think that it would matter, but apparantly it does. Good to know! (I wish I advised you to use the 3.5-configfile to check if it would matter, but I really thought it wouldn't)
Graag gedaan ;)
Hi, could someone please post the solution, the web.config that is. Im having the same problem when using jQuerey. Thx!
The web config for 3.5 i available from codeplex: http://umbraco.codeplex.com/releases/view/33743
is working on a reply...