Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:32:31+00:00 2026-05-13T16:32:31+00:00

I want to create a web method that accepts a List of custom objects

  • 0

I want to create a web method that accepts a List of custom objects (passed in via jQuery/JSON).

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:

System.InvalidOperationException: EditCustomObjects Web Service method name is not valid.

Here’s the web service method:

[WebMethod]
public void EditCustomObjects(int ID, List<CustomObject> CustomObjectList)
{
  // Code here
}

And my jQuery code (which I don’t think matters, since the error seems to be happening on the web service level):

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
  }
});

The customObjectList is initialized like so:

var customObjectList = [];

And I add items to it like so (via a loop):

var itemObject = { 
  ObjectTitle = objectTitle,
  ObjectDescription = objectDescription,
  ObjectValue = objectValue
}

customObjectList.push(itemObject);

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?

FYI, I am running .NET 2.0 on a Windows Server 2003 machine, and I got the code for the above from this site: http://elegantcode.com/2009/02/21/javascript-arrays-via-jquery-ajax-to-an-aspnet-webmethod/

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:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService] 
public class ManageObjects : Custom.Web.UI.Services.Service 
{
}

Bara

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:32:32+00:00Added an answer on May 13, 2026 at 4:32 pm

    I make the assuption based on comments that you can directly go to the web service in the browser.

    Just to isolate your custom object from configuration, you could put another service in place like:

    [WebMethod]
    public static string GetServerTimeString()
    {
        return "Current Server Time: " + DateTime.Now.ToString();
    }
    

    Call that from a client side jQuery ajax call. If this works, then it is probably related to your object specifically and not configuration on the server side. Otherwise, keep looking on the server side config track.

    EDIT: Some sample code:

    [WebMethod(EnableSession = true)]
    public Category[] GetCategoryList()
    {
        return GetCategories();
    }
    private Category[] GetCategories()
    {
         List<Category> category = new List<Category>();
         CategoryCollection matchingCategories = CategoryList.GetCategoryList();
         foreach (Category CategoryRow in matchingCategories)
        {
             category.Add(new Category(CategoryRow.CategoryId, CategoryRow.CategoryName));
        }
        return category.ToArray();
    }
    

    And here is an example of where I post a complex data type JSON value

    [WebMethod]
     public static string SaveProcedureList(NewProcedureData procedureSaveData)
     {
              ...do stuff here with my object
     }
    

    This actually includes two arrays of objects inside it… my NewProcedureData type is defined in a class which lays those out.

    EDIT2:

    Here is how I handle a complex object in one instance:

    function cptRow(cptCode, cptCodeText, rowIndex)
    {
        this.cptCode = cptCode;
        this.cptCodeText = cptCodeText;
        this.modifierList = new Array();
    //...more stuff here you get the idea
    }
    /* set up the save object */
    function procedureSet()
    {
        this.provider = $('select#providerSelect option:selected').val(); // currentPageDoctor;
        this.patientIdtdb = currentPatientIdtdb;// a javascript object (string)
    //...more object build stuff.
        this.cptRows = Array();
        for (i = 0; i < currentRowCount; i++)
        {
            if ($('.cptIcdLinkRow').eq(i).find('.cptEntryArea').val() != watermarkText)
            {
                this.cptRows[i] = new cptRow($('.cptIcdLinkRow').eq(i).find('.cptCode').val(), $('.cptIcdLinkRow').eq(i).find('.cptEntryArea').val(), i);//this is a javscript function that handles the array object
            };
        };
    };
    //here is and example where I wrap up the object
        function SaveCurrentProcedures()
        {
    
            var currentSet = new procedureSet();
            var procedureData = ""; 
            var testData = { procedureSaveData: currentSet };
            procedureData = JSON.stringify(testData);
    
            SaveProceduresData(procedureData);
        };
        function SaveProceduresData(procedureSaveData)
        {
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                data: procedureSaveData,
    the rest of the ajax call...
            });
        };
    

    NOTE !IMPORTANT the procedureSaveData name must match exactly on the client and server side for this to work properly.
    EDIT3: more code example:

    using System;
    using System.Collections.Generic;
    using System.Web;
    
    namespace MyNamespace.NewProcedure.BL
    {
        /// <summary>
        /// lists of objects, names must match the JavaScript names
        /// </summary>
        public class NewProcedureData
        {
            private string _patientId = "";
            private string _patientIdTdb = "";
    
            private List<CptRows> _cptRows = new List<CptRows>();
    
            public NewProcedureData()
            {
            }
    
            public string PatientIdTdb
            {
                get { return _patientIdTdb; }
                set { _patientIdTdb = value; }
            }
           public string PatientId
            {
                get { return _patientId; }
                set { _patientId = value; }
            }
            public List<CptRows> CptRows = new List<CptRows>();
    
    }
    
    --------
    using System;
    using System.Collections.Generic;
    using System.Web;
    
    namespace MyNamespace.NewProcedure.BL
    {
        /// <summary>
        /// lists of objects, names must match the JavaScript names
        /// </summary>
        public class CptRows
        {
            private string _cptCode = "";
            private string _cptCodeText = "";
    
            public CptRows()
            {
            }
    
            public string CptCode
            {
                get { return _cptCode; }
                set { _cptCode = value; }
            }
    
            public string CptCodeText
            {
                get { return _cptCodeText; }
                set { _cptCodeText = value; }
            }
         }
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 390k
  • Answers 390k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Theoretically, it is possible to intercept the WriteFile win32 API… May 15, 2026 at 1:12 am
  • Editorial Team
    Editorial Team added an answer You can use jQuery.param. May 15, 2026 at 1:12 am
  • Editorial Team
    Editorial Team added an answer Java has methods, not functions. The difference is that methods… May 15, 2026 at 1:12 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.