Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET Web Method that accepts a List<CustomObject> is failing with "Web Service method name is not valid."
    primarykey
    data
    text
    <p>I want to create a web method that accepts a List of custom objects (passed in via jQuery/JSON). </p> <p>When I run the website locally everything seems to work. jQuery and ASP.NET and everyone is happy. But when I put it on one of our servers it blows up. jQuery gets a 500 error after the ajax request with the response being:</p> <blockquote> <p>System.InvalidOperationException: EditCustomObjects Web Service method name is not valid.</p> </blockquote> <p>Here's the web service method:</p> <pre><code>[WebMethod] public void EditCustomObjects(int ID, List&lt;CustomObject&gt; CustomObjectList) { // Code here } </code></pre> <p>And my jQuery code (which I don't think matters, since the error seems to be happening on the web service level):</p> <pre><code>var data = JSON.stringify({ ID: id, CustomObjectList: customObjectList }); $.ajax({ type: "POST", url: "/manageobjects.asmx/EditCustomObjects", data: data, contentType: "application/json; charset=utf-8", async: false, dataType: "json", success: function(xml, ajaxStatus) { // stuff here } }); </code></pre> <p>The customObjectList is initialized like so:</p> <pre><code>var customObjectList = []; </code></pre> <p>And I add items to it like so (via a loop):</p> <pre><code>var itemObject = { ObjectTitle = objectTitle, ObjectDescription = objectDescription, ObjectValue = objectValue } customObjectList.push(itemObject); </code></pre> <p>So, am I doing anything wrong here? Is there a better way of passing an array of data from jQuery to an ASP.NET web service method? Is there a way to resolve the "Web Service method name is not valid." error?</p> <p>FYI, I am running .NET 2.0 on a Windows Server 2003 machine, and I got the code for the above from this site: <a href="http://elegantcode.com/2009/02/21/javascript-arrays-via-jquery-ajax-to-an-aspnet-webmethod/" rel="nofollow noreferrer">http://elegantcode.com/2009/02/21/javascript-arrays-via-jquery-ajax-to-an-aspnet-webmethod/</a></p> <p>EDIT: Someone requested some more info on the web service, I'd rather not provide the whole class but here is a bit more that may help:</p> <pre><code>[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class ManageObjects : Custom.Web.UI.Services.Service { } </code></pre> <p>Bara</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload